admin管理员组文章数量:1414605
Hi am try to use bootstrap modal inside of fixed positioned parent element. But seems like its not working as expected. Here is an example,
<div class="fixed">
<div>
<div>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-target="#myModal" data-toggle="modal">
Launch demo modal
</button>
<!-- Modal -->
<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">×</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>
Note: I would like to keep my HTML structure as it is.
Hi am try to use bootstrap modal inside of fixed positioned parent element. But seems like its not working as expected. Here is an example,
<div class="fixed">
<div>
<div>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-target="#myModal" data-toggle="modal">
Launch demo modal
</button>
<!-- Modal -->
<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">×</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>
https://codepen.io/anon/pen/yMPOpo
Note: I would like to keep my HTML structure as it is.
Share Improve this question edited Mar 16, 2017 at 17:44 stackoverfloweth 6,9175 gold badges44 silver badges75 bronze badges asked Mar 16, 2017 at 17:44 Bhargav PatelBhargav Patel 1512 silver badges10 bronze badges 3-
Why do you need to use
position:fixed
? – Lee Taylor Commented Mar 16, 2017 at 17:54 - Because parent element needs to have position as fixed. – Bhargav Patel Commented Mar 16, 2017 at 18:04
- I got it working with same HTML structure and little different CSS. codepen.io/anon/pen/yMPOpo – Bhargav Patel Commented Mar 16, 2017 at 18:09
3 Answers
Reset to default 3You just have to lower the z-index of backdrop of modal,
Try this simple CSS and you are good to go
.modal-backdrop{
z-index:-1;
}
What is the issue? it's not clickable?
Trying setting the modal to position:relative and give it a z-index.
See here: https://codepen.io/anon/pen/wJPWdr
.modal-backdrop.in {
position:relative;
z-index:100;
}
Short answer: Remove fixed
class
Codepen: https://codepen.io/anon/pen/dvZXVG
Here, a question with the same issue: z-index not working with fixed positioning
or MDN documentation: The stacking context
本文标签: javascriptNot able to use modal in parent element with position as fixedStack Overflow
版权声明:本文标题:javascript - Not able to use modal in parent element with position as fixed - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745194480a2647068.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论