bootstrap - 在模态标题内覆盖popover

时间:2017-03-20 13:50:55

标签: jquery html5 twitter-bootstrap css3

我试图在模态标题中添加叠加弹出窗口。但是当弹出窗口显示时,弹出窗口会忽略其原始位置。

HTML

<div id="myModal" class="modal hide fade">
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" 
        aria-hidden="true">&times;</button>
    <div class="pull-right">
      <div class="overlay">
          <a class="btn"
              rel="popover" 
              href="#"
              name="link-menu"
              data-content="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. " 
              data-original-title="A Title"
              data-placement="bottom">
                  popover menu
          </a>
      </div>
    </div>
    <h3>What is Lorem Ipsum?</h3>
</div>
<div class="modal-body">
    <p>    
            Lorem Ipsum is simply dummy text of the printing and typesetting                                        industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </p>
</div>
<div class="modal-footer">
    <a href="#" class="btn">Close</a>
    <a href="#" class="btn btn-primary">Save changes</a>
</div>

<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>

CSS

.overlay {
  position: relative;
  background-color: rgba(0, 0, 0, 0);
}

.overlay.on {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 10;
}

这是我能够实现的一个小提琴。 http://jsfiddle.net/rjrimorin/p6BAD/50/

任何帮助都非常令人满意!谢谢!

2 个答案:

答案 0 :(得分:1)

Updated FIDDLE

从重叠类中删除position: relative,并将position: fixed更改为position: static <{1}}

.overlay.on
$('a[rel=popover]').popover();

  $("a[name='link-menu']").click(function() {
    $("div.overlay").toggleClass("on");
  });
.btn{
  margin-right: 5px;
}

.overlay {
 position: relative;
  background-color: rgba(0, 0, 0, 0);
}
.overlay.on {
  position: static;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;

  z-index: 10;
}

答案 1 :(得分:0)

可能是这样的:

.btn{
  margin-right: 5px;
}

.overlay {
  position: relative;
  background-color: rgba(0, 0, 0, 0);
}
.overlay.on {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.overlay.on {
  position: relative;
  background-color: transparent;
} 
.popover.fade.bottom.in {
  width: 250px;
  left: -50% !important;
}
相关问题