问题
I would like to know what property, or sets of properties, can be used to deactivate, blur or even put darker the background behind a Bootstrap modal.
I am interested in using those same properties somewhere else but I am having trouble finding them when using inspect element (developer tools).
Hoping you guys can help. Thanks in advance!
回答1:
A div .modal-backdrop
is created which is responsible for this... play around to change the color or the opacity of this div
.modal-backdrop {
background: rgba(161, 247, 174, 0.9) !important;
opacity: 0.3 !important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div class="container">
<h2>Modal Example</h2>
<!-- Button to Open the Modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
Open modal
</button>
<!-- The Modal -->
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
Modal body..
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
来源:https://stackoverflow.com/questions/58305525/what-css-property-disables-the-activity-in-the-background-of-a-bootstrap-4-modal