gpt4 book ai didi

html - IE9 FF 和 chrome 中不同的 div 位置

转载 作者:太空宇宙 更新时间:2023-11-04 00:08:21 25 4
gpt4 key购买 nike

我已经问过这个问题,但我没有得到具体的答案。所以我想问一个简化版的问题

我正在制作一个网站并希望将 div 放置在特定高度。我无法以 px 为单位设置 margin-top,就好像浏览器窗口重新调整大小一样,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>

最佳答案

如果您的意思是它“表现疯狂”,即当您更改浏览器大小时 div 不会动态调整它的位置,原因是您定位它的方式。

您已将位置设置为固定,这意味着您通过顶部、底部、左侧、右侧而不是边距定义确切位置。

关于html - IE9 FF 和 chrome 中不同的 div 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14041274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com