I am designing a page using Bootstrap 3. I am trying to use a popover with placement: right
on an input element. The new Bootstrap ensures that if you use
For people who prefer the JavaScript solution. In Bootstrap 4 tip() became getTipElement() and it returns a no jQuery object. So in order to change the width of the popover in Bootstrap 4 you can use:
}).on("show.bs.popover", function() {
$($(this).data("bs.popover").getTipElement()).css("max-width", "405px");
});
You can use attribute data-container="body" within popover
<i class="fa fa-info-circle" data-container="body" data-toggle="popover"
data-placement="right" data-trigger="hover" title="Title"
data-content="Your content"></i>
I had the same problem. Spent quite some time searching for an answer and found my own solution: Add following text to the head:
<style type="text/css"> .popover{ max-width:600px; } </style>
To change the popover width you may override the template:
$('#name').popover({
template: '<div class="popover" role="tooltip" style="width: 500px;"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"><div class="data-content"></div></div></div>'
})
In bootstrap 4 you can simply override default value of bootstrap variable $popover-max-width
in your styles.scss file like so:
$popover-max-width: 300px;
@import "node_modules/bootstrap/scss/functions";
@import "node_modules/bootstrap/scss/variables";
@import "node_modules/bootstrap/scss/mixins";
@import "node_modules/bootstrap/scss/popover";
More on overriding bootstrap 4 defaults https://getbootstrap.com/docs/4.0/getting-started/theming/#variable-defaults
Here's the non-coffeescript way of doing it with hover:
$(".product-search-trigger").popover({
trigger: "hover",
container: "body",
html: true,
placement: "left"
}).on("show.bs.popover", function() {
return $(this).data("bs.popover").tip().css({
maxWidth: "300px"
});
});
});