bootstrap modal 子元素定位为什么是基于模态框?

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>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div 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>
      </div>
      <div class="modal-body">
        <div class="test">test</div>
      </div>
      <div 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>
      </div>
    </div>
  </div>
</div>
阅读 5.6k
评论
    1 个回答
    • 781
      撰写回答

      登录后参与交流、获取后续更新提醒

      相似问题
      推荐文章