Closed jaysonlane closed 5 years ago
Good question, how would you do this with just bootstrap?
@dougludlow thanks for the quick response! I am considering adding a class to the body that indicates which modal (or modal type) is open and then styling the modal backdrop that way. The only potential "gotcha" I can see here is hooking into the modal close to remove that class.
Actually, it may make more sense to just add a class to the modal-backdrop
when the modal is opened. 🤔
I found this solution: https://stackoverflow.com/a/26248333/1110395.
I believe we expose the bootstrap modal instance.
Fantastic, thanks @dougludlow. I'm actually having some success with the css-only suggestion on that same question:
.modal2.fade.in ~ .modal-backdrop.fade.in {
background-color: #f00;
}
Great!
I've got a question:
Is it possible to style the backdrop per modal? I'm not seeing a way to do that without styling every modal. Here's my use case:
Some of my modals need a backdrop, some do not. However, I still want to be able to dismiss the modals that do not have a backdrop by click outside of them so
[backdrop]="false"
won't suffice. To get around this, setting the backdrop opacity to 0 works but I want a visible backdrop on other modals. Haven't found a way to do this yet.