Modal backdrop issue in browser fullscreen mode

I have the following situation:

i have a div element (a mapbox map) that can be displayed in browser fullscreeen mode with a Bootstrap modal inside:

<div id="map-container">
...
  <div class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        ....
      </div>
    </div>
  </div>
</div>

When the map is in full screen mode and I open the modal, I can see the modal, but the backdrop appears behind the map and is therefore not visible. Everything works fine when the map is not in full screen mode.

I found out that when the modal is opened, the backdrop element is added at the end before the body close tag:

<div id="map-container">
...
  <div class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        ....
      </div>
    </div>
  </div>

</div>
....
<div class="modal-backdrop fade show"></div> <!-- ## BEHIND MAP ELEMENT ## -->
</body>

How can i make bootstrap to place the backdrop element inside the map div??

<div id="map-container">
...
  <div class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        ....
      </div>
    </div>
  </div>
  
  <div class="modal-backdrop fade show"></div> <!-- ## THIS SHOULD BE PLACED HERE ## -->

</div>

Thank you.

  • This is not a bug. This is the default behaviour of bootstrap modal.

    – 

  • “How can i make bootstrap to place the backdrop element inside the map div?” – I don’t think it has any direct method to modify this behavior. Your best bet is probably to simply place that element directly where you want it, via your template. You could use the adjacent sibling selector in CSS, to directly show/hide it based on whether the preceding .modal sibling has the show class or not.

    – 




  • (Could you please tag such questions with the actual BS version you are using. That you are using both 4 and 5 simultaneously, is rather unlikely, I suppose.)

    – 

Leave a Comment