javascript - bootstrap modal 子元素定位为什么是基于模态框?
PHP中文网
PHP中文网 2017-04-10 16:42:25
0
1
372

webkit浏览器下bootstrap modal 模态框里的子元素定位为 position:fixed 时,为什么是基于模态框而不是屏幕视窗的位置?
jsfiddle 示例

<style type="text/css">
.test {
  position: fixed;
  top: 0px;
}
</style>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>

<p class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <p class="modal-dialog" role="document">
    <p class="modal-content">
      <p class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </p>
      <p class="modal-body">
        <p class="test">test</p>
      </p>
      <p class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </p>
    </p>
  </p>
</p>
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
Ty80

transform: translate(0,0);引起的,你谷歌搜一下“transform fixed”有挺多解答的~

这不是bug,这是规范的一部分,规范链接
下面是标准答案: https://www.zhihu.com/question/25552699

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template