Bootstrap 3 - modal disappearing below backdrop when using a fixed sidebar

前端 未结 3 1811
陌清茗
陌清茗 2021-01-01 06:28

I have indentified this problem as happening due to the popup getting enclosed in another div with position:fixedthat I cannot avoid due to a fixed sidebar feat

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-01 06:50

    I was in the same situation, and I came up with a nifty CSS trick:

    .modal {
      background: rgba(255, 255, 255, 0.8); /* The color depends on your template */
    }
    .modal-backdrop {
      display: none;
    }
    

    Basically, I make sure that the original backdrop is hidden and I add a transparent white background to the modal container. Turns out the container takes the whole height of the body in order to efficiently center the actual modal.

    However, this trick might not work if your page content is "shorter" than your browser. If your page takes up 60% of your browser's vertical height, the new backdrop will be applied to this 60% only.

提交回复
热议问题