【发布时间】:2017-08-22 15:26:17
【问题描述】:
我在 .Net MVC 4 和 Bootstrap 中有一个 webapp。我需要用模型中的一些数据显示一个模态。我的页面是用模型输入的。问题是这样的: 如果我将模态 div 放在我的页面中(此页面使用布局),则 div 作为模态对话框打开,但看起来变暗并且无法单击。如果我将模态 div 放在主布局中,模态看起来还可以,但是我不能在模态 div 内使用模型,因为我的布局不是模型类型的。一种选择是对我的布局进行建模,另一种选择可能将我的 div 保留在我的页面中,但使用一些将我的模态 div 放在所有前面的属性(如 z-index)。我尝试了最后一个,但没有成功。
我页面中的代码。
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<div id="myModal" class="modal fade" role="dialog" style="z-index: 150;">
<div class="modal-dialog" style="z-index: 151;">
<div class="modal-content" style="z-index: 152;">
<div class="modal-header" style="z-index: 153;">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body" style="z-index: 153;">
<label>Hello @Model.UserName</label>
</div>
<div class="modal-footer" style="z-index: 153;">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
【问题讨论】:
标签: asp.net-mvc bootstrap-modal