C# 引导3模式父页面不不透明?
我有一个MVC应用程序,在my_Layout.cshtml中有一个引导模式声明,我用一些Javascript调用它,将MVC部分视图加载到模式中。一切似乎都很好,除了模式的外部区域没有灰显,向用户显示他们不能单击模式之外的任何地方。换句话说,父页面看起来是活动的,而模式正好位于父页面的顶部 我已经做了一些搜索,但我没有找到任何我可以尝试让它显示为禁用的父页面 这是我在my_Layout.cshtml页面中的代码C# 引导3模式父页面不不透明?,c#,asp.net-mvc,twitter-bootstrap-3,C#,Asp.net Mvc,Twitter Bootstrap 3,我有一个MVC应用程序,在my_Layout.cshtml中有一个引导模式声明,我用一些Javascript调用它,将MVC部分视图加载到模式中。一切似乎都很好,除了模式的外部区域没有灰显,向用户显示他们不能单击模式之外的任何地方。换句话说,父页面看起来是活动的,而模式正好位于父页面的顶部 我已经做了一些搜索,但我没有找到任何我可以尝试让它显示为禁用的父页面 这是我在my_Layout.cshtml页面中的代码 @******** Bootstrap Modal - used with Par
@******** Bootstrap Modal - used with Partial Views ************************@
<div id="modal-container" class="modal fade">
<div class="modal-dialog modal-lg">
<div class="modal-content" id="modal-content">
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
// Attach modal-container bootstrap attributes to links with .modal-link class.
// when a link is clicked with these attributes, bootstrap will display the href content in a modal dialog.
$('body').on('click', '.modal-link', function (e) {
e.preventDefault();
$(this).attr('data-target', '#modal-container');
$(this).attr('data-toggle', 'modal');
});
// Attach listener to .modal-close-btn's so that when the button is pressed the modal dialog disappears
$('body').on('click', '.modal-close-btn', function () {
$('#modal-container').modal('hide');
});
//clear modal cache, so that new content can be loaded
$('#modal-container').on('hidden.bs.modal', function () {
$(this).removeData('bs.modal');
});
$('#CancelModal').on('click', function () {
return false;
});
});
/***** Vertically center Bootstrap 3 modals so they aren't always stuck at the top ********/
$(function () {
function reposition() {
var modal = $(this),
dialog = modal.find('.modal-dialog');
modal.css('display', 'block');
// Dividing by two centers the modal exactly, but dividing by three
// or four works better for larger screens.
dialog.css("margin-top", Math.max(0, ($(window).height() - dialog.height()) / 2));
}
// Reposition when a modal is shown
$('.modal').on('show.bs.modal', reposition);
// Reposition when the window is resized
$(window).on('resize', function () {
$('.modal:visible').each(reposition);
});
});
</script>
@*********引导模式-与局部视图一起使用************************@
$(函数(){
//将模态容器引导属性附加到具有.modal链接类的链接。
//当使用这些属性单击链接时,引导将在模式对话框中显示href内容。
$('body')。在('click','modal link',函数(e)上{
e、 预防默认值();
$(this.attr('data-target','#modal container');
$(this.attr('data-toggle','modal');
});
//将侦听器连接到.modal关闭btn,以便当按下按钮时,模态对话框消失
$('body')。在('click','上。模式关闭btn',函数(){
$(“#模态容器”).modal('hide');
});
//清除模式缓存,以便可以加载新内容
$('#modal container').on('hidden.bs.modal',function(){
$(this.removeData('bs.modal');
});
$('#cancelmodel')。在('click',函数(){
返回false;
});
});
/*****垂直居中引导3模态,这样它们就不会总是停留在顶部********/
$(函数(){
函数重新定位(){
var modal=$(此),
dialog=modal.find('.modal dialog');
css('display','block');
//除以两个中心,模态精确,但除以三
//或者四个更适合大屏幕。
css(“margintop”,Math.max(0,($(window.height()-dialog.height())/2));
}
//显示模式时重新定位
$('.modal')。打开('show.bs.modal',重新定位);
//调整窗口大小时重新定位
$(窗口).on('resize',函数(){
$('.model:visible')。每个(重新定位);
});
});
您使用的是哪个引导版本?确保引导JS和CSS文件版本相互匹配,如果您坚持使用当前版本,请尝试添加
(**=像素分割高度)或在.modal background
&.modal background.fade.in
选择器中设置背景色
属性。谢谢。我会检查所有这些,但这是一个相当新的项目。应该是引导3。