Popup 有人能帮我修一下吗?我需要它在中心对齐,即使你放大你的浏览器
下面是代码,有人能帮我解决这个问题吗,我希望它保持居中,即使你放大浏览器,它也会相对扩展遮罩,试试看,这样你就会知道我在说什么,我不是专家,我还在学习Popup 有人能帮我修一下吗?我需要它在中心对齐,即使你放大你的浏览器,popup,modal-dialog,lightbox,box,Popup,Modal Dialog,Lightbox,Box,下面是代码,有人能帮我解决这个问题吗,我希望它保持居中,即使你放大浏览器,它也会相对扩展遮罩,试试看,这样你就会知道我在说什么,我不是专家,我还在学习 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"&
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple JQuery Modal Window from Queness</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var id = '#dialog';
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set heigth and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow",0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
//transition effect
$(id).fadeIn(2000);
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask').hide();
$('.window').hide();
});
});
</script>
<style type="text/css">
}
a {color:#333; text-decoration:none}
a:hover {color:#ccc; text-decoration:none}
.close {
-moz-box-shadow:inset 0px 1px 0px 0px #ffffff;
-webkit-box-shadow:inset 0px 1px 0px 0px #ffffff;
box-shadow:inset 0px 1px 0px 0px #ffffff;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #f9f9f9), color-stop(1, #e9e9e9) );
background:-moz-linear-gradient( center top, #f9f9f9 5%, #e9e9e9 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#e9e9e9');
background-color:#f9f9f9;
-webkit-border-top-left-radius:20px;
-moz-border-radius-topleft:20px;
border-top-left-radius:20px;
-webkit-border-top-right-radius:20px;
-moz-border-radius-topright:20px;
border-top-right-radius:20px;
-webkit-border-bottom-right-radius:20px;
-moz-border-radius-bottomright:20px;
border-bottom-right-radius:20px;
-webkit-border-bottom-left-radius:20px;
-moz-border-radius-bottomleft:20px;
border-bottom-left-radius:20px;
text-indent:-0.48px;
border:1px solid #dcdcdc;
display:inline-block;
color:#666666;
font-family:Verdana;
font-size:11px;
font-weight:bold;
font-style:normal;
height:18px;
line-height:18px;
width:18px;
text-decoration:none;
text-align:center;
text-shadow:1px 1px 0px #ffffff;
display:inline;
z-index:3200; position:absolute; top: -10px; right:-10px; cursor:pointer;}
}
.close:hover {
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #e9e9e9), color-stop(1, #f9f9f9) );
background:-moz-linear-gradient( center top, #e9e9e9 5%, #f9f9f9 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e9e9e9', endColorstr='#f9f9f9');
background-color:#e9e9e9;
}
#mask {
position:absolute;
left:0;
top:0;
z-index:9000;
background-color:#000;
display:none;
}
#boxes .window {
position:absolute;
left:0;
top:0;
width:440px;
height:200px;
display:none;
z-index:9999;
padding:20px;
}
#boxes #dialog {
width:728px;
height:90px;
padding:10px;
background-color:#ffffff;
}
</style>
</head>
<body>
<div id="boxes">
<div id="dialog" class="window">
<a href="#" class="close">X</a>
</div>
<div style="width: 1478px; height: 602px; display: none; opacity: 0.8;" id="mask"></div>
</div>
</body>
</html>
来自Queness的简单JQuery模式窗口
$(文档).ready(函数(){
变量id='#对话框';
//获取屏幕的高度和宽度
var maskHeight=$(document.height();
var maskWidth=$(window.width();
//设置遮罩的高度和宽度以填充整个屏幕
$('#mask').css({'width':maskWidth,'height':maskHeight});
//过渡效应
$('面具').fadeIn(1000);
$(#mask').fadeTo(“慢”,0.8);
//获取窗口的高度和宽度
var winH=$(window.height();
var winW=$(window.width();
//将弹出窗口设置为居中
$(id).css('top',winH/2-$(id).height()/2);
$(id).css('left',winW/2-$(id).width()/2);
//过渡效应
美元(id).fadeIn(2000年);
//如果单击“关闭”按钮
$('.window.close')。单击(函数(e){
//取消链接行为
e、 预防默认值();
$(“#掩码”).hide();
$('.window').hide();
});
});
}
a{color:#333;文本装饰:无}
a:悬停{颜色:#ccc;文本装饰:无}
.结束{
-moz盒阴影:插入0px 1px 0px 0px#ffffff;
-网络工具包盒阴影:插入0px 1px 0px 0px#ffffff;
盒影:插入0px 1px 0px 0px#ffffff;
背景:-webkit渐变(线性、左上、左下、颜色停止(0.05,#f9f9f9)、颜色停止(1,#e9e9e9));
背景:-莫兹线性梯度(中心顶部,#f9f9f9 5%,#e9e9e9 100%);
过滤器:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9',endColorstr='#e9e9e9');
背景色:#f9f9f9;
-webkit边框左上半径:20px;
-左上角moz边界半径:20px;
边框左上半径:20px;
-webkit边框右上角半径:20px;
-moz边界半径右上角:20px;
边框右上角半径:20px;
-webkit边框右下半径:20px;
-moz边界半径右下角:20px;
边框右下半径:20px;
-webkit边框左下半径:20px;
-moz边框半径左下角:20px;
边框左下半径:20px;
文本缩进:-0.48px;
边框:1px实心#DCDC;
显示:内联块;
颜色:#666666;
字体系列:Verdana;
字体大小:11px;
字体大小:粗体;
字体风格:普通;
高度:18px;
线高:18px;
宽度:18px;
文字装饰:无;
文本对齐:居中;
文本阴影:1px 1px 0px#ffffff;
显示:内联;
z索引:3200;位置:绝对;顶部:-10px;右侧:-10px;光标:指针;}
}
.关闭:悬停{
背景:-webkit渐变(线性,左上,左下,颜色停止(0.05,#e9e9e9),颜色停止(1,#F9F9));
背景:-莫兹线性梯度(中心顶部,#e9e9e9 5%,#f9f9f9 100%);
过滤器:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e9e9e9',endColorstr='#f9f9f9');
背景色:#e9e9e9;
}
#面具{
位置:绝对位置;
左:0;
排名:0;
z指数:9000;
背景色:#000;
显示:无;
}
#盒子,窗户{
位置:绝对位置;
左:0;
排名:0;
宽度:440px;
高度:200px;
显示:无;
z指数:9999;
填充:20px;
}
#对话框{
宽度:728px;
高度:90px;
填充:10px;
背景色:#ffffff;
}
尝试插入
或将整个身体包裹在
中,然后
什么{
文本对齐:居中;
}
在代码的
中的CSS中 试过了,当你放大它时,它仍然会向左移动,而不是停留在屏幕上middle@user3890507您已经使用了以像素(px)为单位的大小和尺寸。改为使用%s。我想这一定会解决你的问题。特别是对于位置
和宽度
属性。例如,不使用top:123px代码>使用<代码>顶部:20%代码>。