Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color of close button in bootstrap modal window

I'm using modal window with boostrap. I've already changed the background and font color, but I did not succed changing the upper right close button to white.

<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true" class="modal_button">&times;</span><span class="sr-only">Close</span></button> 

Here's my css attribute

.modal-header {   border-top: 1px solid white;   border-left: 1px solid white;   border-right: 1px solid white;   text-align: left;   font-size: 23px;   color: white;   background-color: #261f31;   border-bottom: 0px; } 

I would like to turn the X button in white

like image 982
Emmanuel P. Avatar asked Nov 13 '14 20:11

Emmanuel P.


People also ask

Can you change Bootstrap button color?

Bootstrap Button ColorsYou can by using the . btn class in your HTML and the class selector in your CSS.

How do you make a modal close button?

There are few ways to close modal in Bootstrap: click on a backdrop, close icon, or close button. You can also use JavaScript hide method. Click the button to launch the modal. Then click on the backdrop, close icon or close button to close the modal.


2 Answers

Bootstrap is setting the color like this:

.close {   float: right;   font-size: 21px;   font-weight: 700;   line-height: 1;   color: #000;   text-shadow: 0 1px 0 #fff;   filter: alpha(opacity=20);   opacity: .2; } 

So you can override it with this:

.close {     color: #fff;      opacity: 1; } 
like image 137
Steve Sanders Avatar answered Oct 21 '22 23:10

Steve Sanders


In bootstrap 5 they have a class that allows you to change the color to white for the close button.

<button type="button" class="btn-close btn-close-white" aria-label="Close"></button>

like image 39
stromyc Avatar answered Oct 21 '22 22:10

stromyc