I am using bootstrap modal. When modal is open background content opacity is not changed by default. I tried changing in js using
function showModal() { document.getElementById("pageContent").style.opacity = "0.5";
}
This is working but whenever modal is closed opacity style still remains for the pageContent. But, I am sure this is not the right way to do. Any help appreciated. Thanks. Html button which opens Modal is
<button class="btn glossy-clear" data-toggle="modal" data-target="#modal-display" onclick="showModal()">Clear</button>
Modal Code is
<div class="modal fade" id="modal-display"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">Search results</h4> </div> <div class="modal-body"> <div class="container"> <div class="row"> <div class="col-md-5">Hello</div> <div class="col-md-5">i!!!!</div> </div> </div> </div> </div> </div> </div>
EDIT:
fade class adds a transition effect which fades the modal in and out. Remove this class if you do not want this effect. The attribute role="dialog" improves accessibility for people using screen readers.
Modals are built with HTML, CSS, and JavaScript. They're positioned over everything else in the document and remove scroll from the <body> so that modal content scrolls instead. Clicking on the modal “backdrop” will automatically close the modal. Bootstrap only supports one modal window at a time.
I am assuming you want to set the opacity of the modal background...
Set the opacity via CSS
.modal-backdrop { opacity:0.5 !important; }
!important
prevents the opacity from being overwritten - particularly from Bootstrap in this context.
You can override the modal-backdrop opacity in your stylesheet [take note of the .in class]
.modal-backdrop.in { opacity: 0.9; }
http://jsfiddle.net/ThisIsMarkSantiago/r0gwn005/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With