gpt4 book ai didi

css - DIV 绝对定位在 IE 中不起作用

转载 作者:行者123 更新时间:2023-11-28 14:19:49 26 4
gpt4 key购买 nike

以下代码在 IE 中不起作用。尽管 DIV 设置为 left:0pxright:0px,但它并未跨越整个页面。根据调试器,正文元素具有较大的宽度。

为什么?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div align="center" style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; background-color: red">
Some text

</div>
</body>
</html>

最佳答案

你不能在同一个容器中使用“left: 0; right: 0;” left or right and same with top bottom.

使用这个

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div align="center" style="position: absolute; left: 0; top: 0; background-color: red">
Some text

</div>
</body>
</html>

关于css - DIV 绝对定位在 IE 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8653449/

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