I am working with angular and want to create a modal. However I am having a lot of problems removing or editing modal-backdrop as it never takes my values in css.
It is possible to remove through data-backdrop = false, I know, but I intend to close the modal when I click outside of this, it gives not use the data-backdrop.
Can someone experienced help me? I've been at this for days and so far still nothing.
I leave my code and stackblitz to test. Thanks !
Code
HTML
<div class="container">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
Open modal
</button>
<div class="modal fade" id="myModal">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
Modal body..
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
An alternative answer without using !important
(should be avoided when possible)
::ng-deep .modal-backdrop.show {
background: transparent;
}
As shown in this stackblitz https://stackblitz.com/edit/angular-1dh6k3
you can add
.fade.show {
background: red; // example
opacity: 1; // example
}
and you are able to edit the modal backdrop
You can try this:
.modal-backdrop {
opacity: 0 !important;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.