【问题标题】:Placing Bootstrap Dialog Model inside webpage将引导对话框模型放置在网页内
【发布时间】:2015-09-18 18:55:02
【问题描述】:

我在我的网站中使用了 Bootstarp 模态,但是当我尝试通过单击按钮来触发这个模态时

<input type="image" name="ImageButton4" id="ImageButton4" class="bw" data-target="#pnlModal" data-toggle="modal" src="Images/note.png" onclick="javascript:return false;" style="width:15%;" />

它显示了非活动模型作为这张图片!

这是我的 Model CSS 代码,存在于 bootstrap.cs`中

 </div>
    <asp:Panel ID="pnlModal" runat="server" role="dialog" CssClass="modal fade">
        <asp:Panel ID="pnlInner" runat="server" CssClass="modal-dialog" >
            <asp:Panel ID="pnlContent" CssClass="modal-content" runat="server">
                <asp:Panel runat="server" class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">
                        <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                    </button>
                    <h4 class="modal-title">Write Your Note Now ! we'll save it in "D" partition </h4>
                </asp:Panel>
                <asp:panel runat="server" class="modal-body">
                  <asp:TextBox ID="NoteText"  TextMode="MultiLine" CssClass="form-control" Font-Size="Larger" Font-Bold="true" runat="server"></asp:TextBox>
                 </asp:panel>
                <asp:panel runat="server" class="modal-footer">
                    <asp:LinkButton  OnClick="Button1_Click1" ID="Button1" runat="server"  CssClass="btn btn-success"  >Write Now ! </asp:LinkButton>
                </asp:panel>
            </asp:Panel>
        </asp:Panel>
    </asp:Panel>

这都是模态标记

.modal-open {
  overflow: hidden;
}
.modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1050;
  display: none;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
  outline: 0;
}
.modal.fade .modal-dialog {
  -webkit-transition: -webkit-transform .3s ease-out;
       -o-transition:      -o-transform .3s ease-out;
          transition:         transform .3s ease-out;
  -webkit-transform: translate(0, -25%);
      -ms-transform: translate(0, -25%);
       -o-transform: translate(0, -25%);
          transform: translate(0, -25%);
}
.modal.in .modal-dialog {
  -webkit-transform: translate(0, 0);
      -ms-transform: translate(0, 0);
       -o-transform: translate(0, 0);
          transform: translate(0, 0);
}
.modal-open .modal {
  overflow-x: hidden;
  overflow-y: auto;
}
.modal-dialog {
  position: relative;
  width: auto;
  margin: 10px;
}
.modal-content {
  position: relative;
  background-color: #fff;
  -webkit-background-clip: padding-box;
          background-clip: padding-box;
  border: 1px solid #999;
  border: 1px solid rgba(0, 0, 0, .2);
  border-radius: 6px;
  outline: 0;
  -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
          box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
}
.modal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  background-color: #000;
}
.modal-backdrop.fade {
  filter: alpha(opacity=0);
  opacity: 0;
}
.modal-backdrop.in {
  filter: alpha(opacity=50);
  opacity: .5;
}
.modal-header {
  min-height: 16.42857143px;
  padding: 15px;
  border-bottom: 1px solid #e5e5e5;
}
.modal-header .close {
  margin-top: -2px;
}
.modal-title {
  margin: 0;
  line-height: 1.42857143;
}
.modal-body {
  position: relative;
  padding: 15px;
}
.modal-footer {
  padding: 15px;
  text-align: right;
  border-top: 1px solid #e5e5e5;
}
.modal-footer .btn + .btn {
  margin-bottom: 0;
  margin-left: 5px;
}
.modal-footer .btn-group .btn + .btn {
  margin-left: -1px;
}
.modal-footer .btn-block + .btn-block {
  margin-left: 0;
}
.modal-scrollbar-measure {
  position: absolute;
  top: -9999px;
  width: 50px;
  height: 50px;
  overflow: scroll;
}

【问题讨论】:

  • 我遇到了这个问题。试试这个 1. 更新最新的 css 或 2. 将 modal div 放在所有内容之外,即在 body 关闭标签之前。如果这不起作用,那么提供一个渲染的 html 的小提琴
  • @JSantosh 谢谢你的时间,但我不能把它放在外面! .. 它必须放在
    对吗?
  • 哦,然后提供一个渲染html的小提琴
  • @JSantosh 有一个模态开始页面加载..ahmedibrahhim-001-site1.smarterasp.net/…
  • @JSantosh 你能检查一下吗?

标签: jquery asp.net twitter-bootstrap modal-dialog


【解决方案1】:

显然您的.modal 元素位于.modal-backdrop 元素之下。默认情况下,他们的z-index'es 是

.modal-backdrop {
   z-index: 1040;
}
.modal {
   z-index: 1050;
}

其他地方的代码/CSS 中的某些内容破坏了此默认顺序。通过添加上述 CSS after bootstrap.css 和其他 CSS 声明来重新引入 z 顺序。


更新。如果它不起作用,您可以将它放在 &lt;/head&gt;&lt;/body&gt; 之前的最后一件事:

<style type="text/css">
.modal-backdrop {
   z-index: 1040;
}
.modal {
   z-index: 1050;
}
</style>

【讨论】:

  • 谢谢先生,但我是bootstrap模型的初学者,你的回答很清楚,但我看不懂! .. 我应该更改z-index:1040 哪个内部按钮?还是把它放在 css 模型中?
  • 非常感谢,但是我可以在stackoverflow之外与您保持联系吗,因为它可能会被视为在这里聊天
  • @AhmedIbrahim,这里已经很晚了,但是如果你想分享一个链接,只需在评论中添加它,然后我明白了,然后你可以删除该评论。
  • @AhmedIbrahim 你能分享一个链接吗?无论如何,它都应该可以正常工作 - 一个奇怪的选择是模态容器是否位于具有固定或相对位置的元素内,但如果没有看到标记和 CSS 就无法判断。您能否将完整的标记添加到您的问题中,即呈现的标记 - 而不是 ASP?
  • @AhmedIbrahim 已经翻译了您的 asp 标记并包含了 CSS -> jsfiddle.net/ga8hrpnn 它工作正常,所以它是导致问题的模态元素周围的东西。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-24
  • 2016-11-29
  • 1970-01-01
相关资源
最近更新 更多