Reputation: 19
I was trying to add overlay popover inside modal header. but when popover was shown, the popover ignores the its original position.
HTML
<div id="myModal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
<div class="pull-right">
<div class="overlay">
<a class="btn"
rel="popover"
href="#"
name="link-menu"
data-content="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. "
data-original-title="A Title"
data-placement="bottom">
popover menu
</a>
</div>
</div>
<h3>What is Lorem Ipsum?</h3>
</div>
<div class="modal-body">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>
<div class="modal-footer">
<a href="#" class="btn">Close</a>
<a href="#" class="btn btn-primary">Save changes</a>
</div>
<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
CSS
.overlay {
position: relative;
background-color: rgba(0, 0, 0, 0);
}
.overlay.on {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 10;
}
Here's a fiddle of what I have been able to achieve. http://jsfiddle.net/rjrimorin/p6BAD/50/
Any help is greatly APPRECIATED! Thank you!
Upvotes: 0
Views: 810
Reputation: 421
May be this:
.btn{
margin-right: 5px;
}
.overlay {
position: relative;
background-color: rgba(0, 0, 0, 0);
}
.overlay.on {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 10;
}
.overlay.on {
position: relative;
background-color: transparent;
}
.popover.fade.bottom.in {
width: 250px;
left: -50% !important;
}
Upvotes: 0
Reputation: 6624
remove position: relative
from overlay class and change position: fixed
to position: static
for .overlay.on
$('a[rel=popover]').popover();
$("a[name='link-menu']").click(function() {
$("div.overlay").toggleClass("on");
});
.btn{
margin-right: 5px;
}
.overlay {
position: relative;
background-color: rgba(0, 0, 0, 0);
}
.overlay.on {
position: static;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 10;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div id="myModal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
<div class="pull-right">
<div class="overlay">
<a class="btn"
rel="popover"
href="#"
name="link-menu"
data-content="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. "
data-original-title="A Title"
data-placement="bottom">
popover menu
</a>
</div>
</div>
<h3>What is Lorem Ipsum?</h3>
</div>
<div class="modal-body">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>
<div class="modal-footer">
<a href="#" class="btn">Close</a>
<a href="#" class="btn btn-primary">Save changes</a>
</div>
</div>
<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
Upvotes: 1