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
I used this(working fine) :
.popover{
background-color:#b94a48;
border:none;
border-radius:unset;
min-width:100px;
width:100%;
max-width:400px;
overflow-wrap:break-word;
}
you can also add the data-container="body" which should do the job :
<div class="row">
<div class="col-md-6">
<label for="name">Name:</label>
<input id="name" class="form-control" type="text"
data-toggle="popover" data-trigger="hover"
data-container="body"
data-content="My popover content.My popover content.My popover content.My popover content." />
</div>
</div>
In Angular ng-bootstrap
you can simply container="body"
to the control that triggers popover (such as button or textbox). Then in your global styleing file (style.css
or style.scss
) file you must add .popover { max-width: 100% !important; }
. After that, the content of the popover will automatically set to its content width.
To change width you can use css
For fixed size wanted
.popover{
width:200px;
height:250px;
}
For max width wanted:
.popover{
max-width:200px;
height:250px;
}
jsfiddle: http://jsfiddle.net/Rqx8T/2/
<label id="txtLbl">Overview</label> <a tabindex="0" class="btn btn-default" role="button" data-toggle="popover" data-placement="right" id="Pops" ></a>
<div id="popover-content" class="hide">
<div class="popovermenu">
Your content
</div>
</div>
I end up by setting div "popover-content" width to the number I want. (other ids or class won't work.....) Good luck!
#popover-content{
width: 600px;
}
You can change the template of your popover. Either with the data-template
-attribute or with the relevant part in the function that sets it up:
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<span class="text-green" data-toggle="popover" data-placement="right" data-template="<div class="popover fade top in" style="max-width:none;" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>" data-trigger="manual" data-original-title="Some Title" data-content="<div>Some really long text and stuff. Some really long text and stuff. Some really long text and stuff. Some really long text and stuff.</div>" data-html="true" onclick="$(this).popover('show');">clickme</span>
</body>
</html>