gamer
gamer

Reputation: 5863

bootstrap modal show with black disabled background

I have a bootstrap modal like:

<div class="modal show" id="myModal" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">My Modal</h4>
      </div>
      <div class="modal-body">
        <p>My Modal Body</p>
      </div>
    </div>
  </div>
</div>

It shows me the model at start but what I want is the background to be black.. or say like transparent when this modal appears and the background should be disabled ..

How can I do that?

Upvotes: 0

Views: 1110

Answers (1)

Markus Wagner
Markus Wagner

Reputation: 181

If you use the class modal show you can manually add <div class="modal-backdrop fade in"></div>, so the resulting code looks like:

<div class="modal show" id="myModal" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">My Modal</h4>
      </div>
      <div class="modal-body">
        <p>My Modal Body</p>
      </div>
    </div>
  </div>
</div>
<div class="modal-backdrop fade in"></div>

If you use modal fade as class, the modal-backdrop should appear automatically.

See: http://jsfiddle.net/dvv6dvug/

Upvotes: 1

Related Questions