怎样让一个层在不同分辨率的显示器上都居中显示 怎样让一个层在不同分辨率的显示器上都居中显示 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!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=gb2312" /><title>无标题文档</title><style type="text/css">html, body{ width:100%; height:100%; margin:0px; padding:0px;}#t{ width:200px; height:100px; border:1px solid #006699; background:#F5F6FB; color:#006699;}</style><script type="text/javascript">window.onload = function(){ var div = document.getElementById("t"); div.style.position = "absolute"; div.style.left = ((document.body.clientWidth || document.documentElement.clientWidth) - div.offsetWidth) / 2 + "px"; div.style.top = ((document.body.clientHeight || document.documentElement.clientHeight) - div.offsetHeight) / 2 + "px";};</script></head><body><div id="t"> 1111111111</div></body></html> 晕,还用什么JS啊直接CSS搞定<!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=gb2312" /><title>无标题文档</title><style type="text/css">body{ margin:0px auto; padding:0px;}#t{ width:200px; height:100px; border:1px solid #006699; background:#F5F6FB; color:#006699; margin:0px auto;padding:0px;}</style></head><body><div id="t"> 1111111111</div></body></html> 上下居中?还是左右居中?还是屏幕居中?屏幕居中的话,就JS吧CSS不知道可以没 呵呵,屏幕居中貌似也可以用CSS你试试<!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=gb2312" /><title>无标题文档</title><style type="text/css">body{ margin:0px auto; padding:0px; width:100%; height:100%;}#t{ width:200px; height:100px; border:1px solid #006699; background:#F5F6FB; color:#006699; margin:0px auto;padding:0px; position:absolute; left:40%; top:40%;}</style></head><body><div id="t"> 1111111111</div></body></html> 呵,用CSS在实际项目中可能会有问题.<!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=gb2312" /><title>无标题文档</title><style type="text/css">html, body{ width:100%; height:100%; margin:0px; padding:0px;}#t{ position:absolute; left:50%; top:50%; margin-left:-100px; margin-top:-50px; width:200px; height:100px; border:1px solid #006699; background:#F5F6FB; color:#006699;}</style></head><body><div id="t"> 1111111111</div></body></html> 一道面试题javascript 去掉重复的字符串组合 有关jsp调用控件的难题 怎样实现把文件另存到另一个位置? div层移动的问题?????? 如何提高自己的编程能力 正确地说,DHTML、XHTML分别是什么?有哪些共同的东西?有哪些不同的内容? 请问如何取得上次访问过的url(flash中的链接) 关于用javascript抵御重放攻击 javascript数组的长度不能超过多大 界面加载完之后的问题 请问:怎样阻止图片自动发送request请求 不知道能不能实现?请高手指点
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
html, body{
width:100%; height:100%; margin:0px; padding:0px;
}
#t{
width:200px; height:100px; border:1px solid #006699; background:#F5F6FB; color:#006699;
}
</style>
<script type="text/javascript">
window.onload = function(){
var div = document.getElementById("t");
div.style.position = "absolute";
div.style.left = ((document.body.clientWidth || document.documentElement.clientWidth) - div.offsetWidth) / 2 + "px";
div.style.top = ((document.body.clientHeight || document.documentElement.clientHeight) - div.offsetHeight) / 2 + "px";
};
</script>
</head><body>
<div id="t">
1111111111
</div>
</body>
</html>
直接CSS搞定
<!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=gb2312" />
<title>无标题文档</title><style type="text/css">
body{
margin:0px auto; padding:0px;
}
#t{
width:200px; height:100px; border:1px solid #006699; background:#F5F6FB; color:#006699;
margin:0px auto;padding:0px;
}
</style>
</head><body><div id="t">
1111111111
</div>
</body>
</html>
屏幕居中的话,就JS吧
CSS不知道可以没
<!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=gb2312" />
<title>无标题文档</title><style type="text/css">
body{
margin:0px auto; padding:0px; width:100%; height:100%;
}
#t{
width:200px; height:100px; border:1px solid #006699; background:#F5F6FB; color:#006699;
margin:0px auto;padding:0px;
position:absolute;
left:40%;
top:40%;
}
</style>
</head><body><div id="t">
1111111111
</div>
</body>
</html>
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
html, body{
width:100%; height:100%; margin:0px; padding:0px;
}
#t{
position:absolute; left:50%; top:50%; margin-left:-100px; margin-top:-50px;
width:200px; height:100px; border:1px solid #006699; background:#F5F6FB; color:#006699;
}
</style>
</head><body>
<div id="t">
1111111111
</div>
</body>
</html>