如何使弹出窗口在屏幕中心和覆盖/背景到全屏高
how to make popup in center of screen and overlay/background to full screen high
我正在开发asp.net页面。在母版页中,我有一个类似的div:
<body id="page1" >
<form id="form2" runat="server">
<div id="content">
<!-- this is popup light grey show -->
<div class="darkenBg" id="popupBackground" style="display:none;"></div>
<!-- content -->
<div class="greenBox2 popUpWin" id="companySigninPopup" style="display:none;">
<div class="topWrap">
<!-- popup window -->
</div>
<div class="botWrap">
<div class="corner-bottom-left"> </div>
<div class="border-bottom"> </div>
<div class="corner-bottom-right"> </div>
</div>
</div>
</div>
</div>
</div>
我展示的是这样的:
function ShowHomePagePopup(popupId) {
$("#" + popupId).show();
$("#popupBackground").show();
$('#popupBackground').height(800);
$("#page1").addClass('hideScrollbars');
}
css是这样的:
html, body {
height:100%;
margin:0px;
}
.darkenBg { /*added this div after body*/
background: url(/images/blackBg.png);
position:absolute;
z-index:30;
width:100%;
height:100%;
bottom:0px;
}
.popUpWin {
position:absolute;
z-index:31;
width:500px;
left:50%;
margin:200px 0 0 -250px
}
.hideScrollbars {
overflow: hidden;
}
#content {
background:url(/images/bg.gif) top left repeat-x #fff;
overflow:hidden;
padding-bottom:20px;
}
- 当弹出窗口出现时,它水平居中,但垂直位于顶部,因此它位于屏幕的中上角
- 覆盖,浅灰色背景,意味着弹出背景只有屏幕高度的10%,尽管宽度是100%。我怎样才能把它做到100%高
这是一个只使用CSS:弹出窗口的好方法
HTML代码:
<div class="container-popup">
<div class="popup"></div>
</div>
CSS代码:
.container-popup {
position: relative;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,.8);
}
.popup {
width: 50%;
height: 50%;
background: #1abcb9;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
}
选中此Fiddle。
有一个最简单的叠加弹出的例子
链接
$(document).ready(function(){
$(".container-popup, #close").click(function(){
$('.popup').hide(); $('.container-popup').hide();
});
});
将弹出窗口放置在覆盖div内!
<body id="page1" style="height: 100%;">
<form id="form2" runat="server" style="min-height: 100%;">
<div id="content">
..
content
...
</div>
</div>
<div class="darkenBg" id="popupBackground" style="display:none;">
<div class="greenBox2 popUpWin" id="companySigninPopup" style="display:none;">
<div class="topWrap">
popup window
</div>
<div class="botWrap">
<div class="corner-bottom-left"> </div>
<div class="border-bottom"> </div>
<div class="corner-bottom-right"> </div>
</div>
</div>
</div>
</form>
</div>
相关文章:
- 防止模式背景覆盖在每个打开的新模式上变得更暗
- 根据覆盖的背景区域的亮度更改文本颜色
- 多个背景图像,一个覆盖另一个
- 在具有动态高度的背景图像上创建渐变覆盖
- 如何防止引导模式对话框的背景覆盖整个屏幕
- 如何在滚动/调整大小时保持背景图像覆盖屏幕
- JavaScript 动态创建覆盖背景
- 如何模拟背景大小:在
上覆盖
- 如何在移动浏览器中制作固定背景以覆盖整个屏幕
- Twitter Bootstrap 模态背景不会覆盖 iPad 上的整个屏幕
- 由视频覆盖的引导导航栏 - 如何用不透明背景覆盖它
- 覆盖在“背景大小:包含”上的响应式 DIV - 解决警报触发的问题
- 引导活动选项卡通过覆盖背景可见
- 网站背景图片没有覆盖
- 如何单击未完全覆盖背景的对象,并在悬停时消失,同时通过窗口对象退出元素
- 整页.js背景图像未覆盖
- 如何使弹出窗口在屏幕中心和覆盖/背景到全屏高
- 在asp.net页面上制作100%高度的覆盖/浅色背景
- 覆盖背景:在CSS中使用背景色的url
- IPhone 4链接创建红色半透明背景/覆盖触摸:激活