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 a typescript component:
@Component({
selector: "your-component",
templateUrl: "your-template.component.html",
styles: [`
:host >>> .popover {
max-width: 100%;
}
`]
})
Try this:
var popover_size=($('.popover').css('width'));
var string=(popover_size).split('px');
alert("string"+string);
popover_size = ((parseInt(string[0])+350));
alert("ps"+popover_size);
$('.popover').css('width',parseInt(popover_size));
No final solution here :/ Just some thoughts how to "cleanly" solve this problem...
Updated version (jQuery 1.11 + Bootstrap 3.1.1 + class="col-xs-" instead of class="col-md-") of your original JSFiddle: http://jsfiddle.net/tkrotoff/N99h7/
Now the same JSFiddle with your proposed solution: http://jsfiddle.net/tkrotoff/N99h7/8/
It does not work: the popover is positioned relative to the <div class="col-*">
+ imagine you have multiple inputs for the same <div class="col-*">
...
So if we want to keep the popover on the inputs (semantically better):
.popover { position: fixed; }
: but then each time you scroll the page, the popover will not follow the scroll.popover { width: 100%; }
: not that good since you still depend on the parent width (i.e <div class="col-*">
.popover-content { white-space: nowrap; }
: good only if the text inside the popover is shorter than max-width
See http://jsfiddle.net/tkrotoff/N99h7/11/
Maybe, using very recent browsers, the new CSS width values can solve the problem, I didn't try.
One tested solution for Bootstrap 4 beta:
.popover {
min-width: 30em !important;
}
Together with the jQuery statement:
$('[data-toggle="popover"]').popover({
container: 'body',
trigger: 'focus',
html: true,
placement: 'top'
})
Side-note, data-container="body"
or container: "body"
in either HTML or as an option
to the popover({})
object didn't really do the trick [maybe the do work but only together with the CSS statement];
Also, remember that Bootstrap 4 beta relies on popper.js for its popover and tooltip positioning (prior to that it was tether.js)
With the help of what @EML has described above regarding popover on modal windows and also the code shown by @2called-chaos, this is how I solved the problem.
I have a icon on the modal which when clicked should the popup
My HTML
<i title="" class="glyphicon glyphicon-info-sign" rel="popover" data-title="Several Lines" data-content="A - First line<br />B - Second line - Long line <br />C - Third Line - Long Long Long Line"></i>
My Script
$('[rel=popover]').popover({
placement: 'bottom',
html: 'true',
container: '#name-of-modal-window .modal-body'
}).on("show.bs.popover", function () { $(this).data("bs.popover").tip().css("max-width", "600px"); });