我正在尝试使用 Bootstrap 3 模态窗口从我正在设计的网站的页眉中启动一个表单。这是链接;模式应该从“电子邮件注册”启动:
http://pamaphilly.wpengine.com/
问题是“固定 Logo 功能区”应该是页面顶部的持久固定元素。但是,当我使用固定定位时,模态无法正常工作。但是,如果我删除固定定位,它会按预期运行。观看此视频:http://screencast.com/t/LeFCDXuf0GrE
我正在更改的 CSS 类是:
.fixed-logo-ribbon {
background-color: #e41535;
height: 4.75em;
width: 100%;
min-height: 5em;
top: 0;
border: 0;
}
此外,html 只是标准模式演示:
<div class="fixed-logo-ribbon">
<div class="container logo-container">
<a href="http://pamaphilly.wpengine.com/">
<img class=logo-PAMA type="image/svg+xml" src="<?php bloginfo('template_url'); ?>/img/PAMA-logo-2014-masthead.svg" height="40" width="360" alt="PAMA-logo">
</a><!-- end logo div -->
<div class="social-media-icons pull-right">
<div class="join-us less-margin">
<a data-toggle="tooltip" data-placement="bottom" title="Join the AMA Now" class="join-link" target="_blank" href="http://www.jointheama.com/">join now</a>
</div>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg join-us" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">×</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</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>
</div>
</div>
</div>
有谁知道如何让模态正常工作,同时仍然有固定的标题,如预期的那样?
在此先感谢您的帮助...
戴夫
最佳答案
根据官方文档:
Modal markup placement
Always try to place a modal's HTML code in a top-level position in your document to avoid other components affecting the modal's appearance and/or functionality.
您的错误也称为 Bootlint problem ID E022
.
解决方法是移动 <div class="modal ...">...</div>
所以它是 <body>
的直接子代,而不是导航栏的后代。
关于javascript - Bootstrap 3 模态在放置在固定父级中时无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27411179/