简体   繁体   English

“数据删除”自举程序模式Bugando,位置=“绝对”

[英]“data-dismiss” Bootstrap modal Bugando with position = “absolute”

I am adding a close button by customizing the modal bootstrapping. 我通过自定义modal自举添加了一个关闭按钮。

I want it on the right of modal for that I gave a 'position: absolute or position: fixed and modified the top and right` it. 我希望它在modal右边,因为我给了它一个“位置:绝对位置or位置:固定and modified the顶部and右侧”。

The problem is that in doing so the button becomes unusable. 问题在于这样做时按钮变得不可用。 From what I gather, there is a conflict between the data-dismiss: modal (attribute that makes the element closing the modal) with the 'position: absolute`. 据我所知, data-dismiss: modal (属性使元素关闭模态)与“位置:绝对”之间存在冲突。

I tried other ways to make such "button" importing a .svg, create a <button> , <span> in addition to changing the position: absolute by float: right . 我尝试了其他方法来使这样的“按钮”导入.svg,除了更改position: absolute通过float: right来创建<button><span> By doing so, only a small portion of the button area becomes the link to close and not the whole area. 这样,只有一小部分按钮区域成为关闭链接,而不是整个区域。 Experience in mobile and desktop is pretty nasty as it is necessary to press / click several times to find the right area, and the right is ALL button area to be a link to close the modal . 在移动和台式机上的体验非常讨厌,因为必须按/单击几次才能找到合适的区域,而右边的“全部”按钮区域是关闭modal的链接。

The following code snippet and to become more clear: 下面的代码片段将变得更加清晰:

 .close-modal { position: absolute; /* REMOVE `POSITION` AND THE BUTTON WORKS */ width: 75px; height: 75px; background-color: transparent; right: 35px; top: 25px; cursor: pointer } .close-modal:hover { opacity: .3; } .lr { height: 75px; width: 1px; margin-left: 35px; background-color: #222; transform: rotate(45deg); -ms-transform: rotate(45deg); -webkit-transform: rotate(45deg); z-index: 1051; } .rl { height: 75px; width: 1px; background-color: #222; transform: rotate(90deg); -ms-transform: rotate(90deg); -webkit-transform: rotate(90deg); z-index: 1051; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> <a href="#modal" class="portfolio-link" data-toggle="modal"> CALL MODAL </a> <div class="portfolio-modal modal fade" id="modal" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-content"> <div class="close-modal" data-dismiss="modal"> <div class="lr"> <div class="rl"> </div> </div> </div> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2"> <div class="modal-body"> <p>CONTENT MODAL CONTENT MODAL</p> <p>CONTENT MODAL CONTENT MODAL</p> <p>CONTENT MODAL CONTENT MODAL</p> </div> </div> </div> </div> </div> </div> 

How I can solve this? 我该如何解决?

There is some another element stacked on top of your close button. 关闭按钮上方还有一些其他元素。 Setting z-index to a high value would make your dismiss button work. 将z-index设置为较高的值将使您的关闭按钮起作用。 This would make the close-modal button at the top and thus clickable. 这将使模式关闭按钮位于顶部,因此可以单击。 You can do this by: 您可以通过以下方式做到这一点:

.close-modal{
  z-index: 1100;
  position: absolute;
  ...
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM