不同div位置我已经问过这个问题,但我没有得到一个具体的答案。所以我想问一个简化版本的问题在IE9 FF和铬
我正在制作一个网站,并希望将div放在特定的高度。我无法像px一样设置页边距,就好像浏览器窗口重新调整大小,div仍然保留在px中。我已经在%中指定了这个。如果margin-top在px中,那么在所有浏览器中都可以,但如果它是%,那么IE9 IE10和FF的表现会很疯狂。
下面的代码非常简单,没有什么困难。我什至尝试重置CSS,但没有得到它的权利。任何人都可以请一些时间来帮助我。
而我目前正在从硬盘上加载网页,而不是从网上下载。
感谢
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Train of Thought</title>
<style type="text/css">
div.content {
height:200px;
visibility:visible;
border-style: none;
display: block;
position: fixed;
text-align: center;
z-index: 1;
padding-top: 0px;
border-top: 0px;
padding-bottom: 0px;
border-bottom: 0px;
background-color: #00FFFF;
font-family:Arial,sans-serif;
overflow: auto;
margin-left: 23%;
margin-right:25%;
font-size:150%;
margin-top: 40%;
}
</style>
</head>
<body>
<div class="content">This div is supposed to be same in all the browsers. but thisis different in them. IE9 and FF display it in lower bottom of the page while chrome displays in the middle.
<br>This div is supposed to be same in all the browsers. but thisis different in them. IE9 and FF display it in lower bottom of the page while chrome displays in the middle.
</div>
</body>
</html>
我测试了你的代码,它在IE9,IE10和FF中按预期工作。请在IE9,IE10和FF中定义''表现疯狂' –
'的含义,div出现在谷歌浏览器的下方。我希望它能在闪烁的chrome显示它的位置。 –
在Firefox上进行测试时,我注意到'margin-top:40%'参数的值是可用宽度的40%,而不是可用高度的40%,如您所料。 –