search

Home  >  Q&A  >  body text

After a recent chrome update, the Bootstrap modal background is displayed in front of the modal

Chrome version: Version 111.0.5563.64 (official version) (x86_64) Bootloader: 4.3.1

Recent chrome updates make the modal background appear in front of the modal itself. I checked that it was not a z-index problem, but I don't know what caused it.

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: 100vw;
    height: 100vh;
    background-color: #000;
}
.modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    display: block;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}
<div class="modal fade" id="aboutUs" tabindex="-1" role="dialog" aria-labelledby="aboutUsModalLabel"
        aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">{{ property.othersPopupTitle | translate: langPreference }}</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <a (click)="tncOnClick()" class="select-wrapper">
                            <label>{{ property.tnc | translate: langPreference }}</label>
                        </a>
                        
                        <a class="select-wrapper" href="{{'tel:'+ contactUs}}" *ngIf="isMobileDevice">
                            <div class="select-icon"></div>
                            <label>{{ property.contactUs | translate: langPreference }}</label>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>


P粉512363233P粉512363233329 days ago592

reply all(2)I'll reply

  • P粉478188786

    P粉4781887862024-01-08 12:37:14

    Watch out for Chrome extensions. I found that "Schema Generator for Structured Data" adds this rule as Inject Stylesheet:

    .modal-backdrop {
        z-index: 2147483647 !important;
    }

    Try disabling them one by one.

    reply
    0
  • P粉475315142

    P粉4753151422024-01-08 11:17:58

    Do not downgrade bootstrap.
    Just add the background to .modal and .modal-backdrop to None in the main style file (style.css).
    Don’t forget The main style.css file is called after the bootstrap file in angular.json.

    .modal {
      background: rgba(0, 0, 0, 0.5); 
    }
    .modal-backdrop {
      display: none;
    }

    reply
    0
  • Cancelreply