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() {
doc
you can set the opacity by the last parameter of rgb
function.
the opacity is 0.5
in the example
.modal-backdrop {
background-color: rgb(0, 0, 0, 0.5);
}
use this code
$("#your_modal_id").on("shown.bs.modal", function(){
$('.modal-backdrop.in').css('opacity', '0.9');
});
You can download a custom compiled bootstrap 3, just customize the @modal-backdrop-opacity from:
https://getbootstrap.com/docs/3.4/customize/
Customizing bootstrap 4 requires compiling from source, overriding $modal-backdrop-bg as described in:
https://getbootstrap.com/docs/4.4/getting-started/theming/
In the answers to Bootstrap 4 custom build generator / download there is a NodeJS workflow for compiling Bootstrap 4 from source, alone with some non-official Bootstrap 4 customizers.
Just in case someone is using Bootstrap 4. It seems we can no longer use .modal-backdrop.in
, but must now use .modal-backdrop.show
. Fade effect preserved.
.modal-backdrop.show {
opacity: 0.7;
}
Adding !important to .modal-backdrop will ruin the transition on bootstrap modal
I achieved changing modal overlay background by direct edit in bootstrap.min.css. Those who are using bootstrap CSS locally (without using CDN) can change the background-color value of .modal-backdrop class.
If you want to change bootstrap 4 modal overlay opacity find this class .modal-backdrop.show and change opacity to the value you need.
If want to change overlay transition timing add transition to .modal-backdrop.fade class
If want to change transition timing for modal object change transition values in .modal.fade .modal-dialog class
It should work with:
.modal:before{
opacity:0.001 !important;
}