To change the color via:
CSS
Put these styles in your stylesheet after the bootstrap styles:
.modal-backdrop {
background-color: red;
}
Less
Changes the bootstrap-variables to:
@modal-backdrop-bg: red;
Source
Sass
Changes the bootstrap-variables to:
$modal-backdrop-bg: red;
Source
Bootstrap-Customizer
Change @modal-backdrop-bg to your desired color:
getbootstrap.com/customize/
You can also remove the backdrop via Javascript or by setting the color to transparent.
To change the color via:
CSS
Put these styles in your stylesheet after the bootstrap styles:
.modal-backdrop {
background-color: red;
}
Less
Changes the bootstrap-variables to:
@modal-backdrop-bg: red;
Source
Sass
Changes the bootstrap-variables to:
$modal-backdrop-bg: red;
Source
Bootstrap-Customizer
Change @modal-backdrop-bg to your desired color:
getbootstrap.com/customize/
You can also remove the backdrop via Javascript or by setting the color to transparent.
If you want to change the background color of the backdrop for a specific modal, you can access the backdrop element in this way:
$('#myModal').data('bs.modal').$backdrop
Then you can change any css property via .css jquery function. In particular, with background:
$('#myModal').data('bs.modal').$backdrop.css('background-color','orange')
Note that $('#myModal') has to be initialized, otherwise $backdrop is going to be null. Same applies to bs.modal data element.
To change the backdrop color you can use this:
.modal-backdrop {
background-color: #0000ff;
}
or separate into clases:
.modal-blue .modal-backdrop {
background-color: #0000ff;
}
.modal-white .modal-backdrop {
background-color: #ffffff;
}
and then add the class to your div:
<div class="modal fade modal-white" ... >
<div class="modal-dialog">
...
</div>
</div>
to stop sliding down remove the "fade" class.
Hope this help,
regards.
Easy remedy is to override the default. Just use:
.fade.in {
background: #000; // or whatever you like
}
You can use the css below, put this in your custom css to override the bootstrap css.
.modal-header {
padding:9px 15px;
border-bottom:1px solid #eee;
background-color: #0480be;
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
So, I tried these other ways, but there was a VERY slight irritant and that was if you keep the modal-content border radius, in FF and Chrome, there is a slight bit of white trim showing along the borders, even if you use 5px on the modal-header border radius. (standard modal-content border radius is 6px, so 5px on the modal-header border top radius covers some white).
My solution:
.modal-body
{
background-color: #FFFFFF;
}
.modal-content
{
border-radius: 6px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
background-color: transparent;
}
.modal-footer
{
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
-webkit-border-bottom-right-radius: 6px;
-moz-border-radius-bottomleft: 6px;
-moz-border-radius-bottomright: 6px;
}
.modal-header
{
border-top-left-radius: 6px;
border-top-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-webkit-border-top-right-radius: 6px;
-moz-border-radius-topleft: 6px;
-moz-border-radius-topright: 6px;
}
!! CAVEAT !!
You must then set the background colors of the modal-header, modal-content, and modal-footer. This is not bad trade-off, because it allows you to do this:
<div class="modal-header bg-primary">
<div class="modal-body bgColorWhite">
<div class="modal-footer bg-info">
EDIT
Or even better:
<div class="modal-header alert-primary">
If you want to update modal backdrop you could use CSS like:
.modal-backdrop {
background-color: green;
}
If you want to change modal background then use:
<Modal className="my-modal" show={show}>
and define in CSS:
.my-modal .modal-content {
background-color: red;
}
You need to appy CSS to modal-content class to change background-color.
Add a class name to your modal where you want to apply background color,
<Modal
show={this.state.show}
onHide={this.handleClose}
dialogClassName="modal-90w public-profile-modal-class"
size='lg'
aria-labelledby="example-custom-modal-styling-title"
className="special_modal" //Add class name here
>
Use that class name to apply CSS
.special_modal .modal-content{
background-color: #000;
color: #fff;
}
Demo
You can try to use the following CSS:
.modal-header {
background-color: darkblue;
color: white;
}
Fiddle is here.
Rather than changing the colours of all the modals why not add this to an extension CSS file.
.modal-header.primary {
color: #fff;
background-color: #337ab7;
border-color: #337ab7;
}
and then add primary to your modal-header thus:
<div class="modal-header primary">
Fiddle is here...
As I can see Bootstrap have the class .modal-backdrop and they are setting the background color to black, you can overwrite this with this code:
.modal-backdrop {
background-color: rgba(0,0,0,.0001) !important;
}
if you are using Bootstrap 4, you could just set the attribute "data-backdrop" in the HTML of the "open modal" button to "false".
e.g. <button data-backdrop="false">Open modal</button>