gpt4 book ai didi

html - css:为什么文本会在删除位置后向上移动:绝对

转载 作者:太空宇宙 更新时间:2023-11-03 23:56:46 26 4
gpt4 key购买 nike

HTML代码:

<!DOCTYPE html>
<html>
<head>
<style>
h2 { position:absolute;}
</style>
</head>
<body>
<h2>This is a heading with an absolute position</h2>
</body>
</html>

问题:

如果我删除这一行:position:absolute; , <h2>...</h2> 中的文本会向上移动,为什么?

最佳答案

在默认 View 中,没有 CSS...

position: absolute; 存在时,边距不会折叠。

enter image description here


当您删除 position: absolute; 时,边距会塌陷,并且会与正文的边距混合在一起。

enter image description here

关于html - css:为什么文本会在删除位置后向上移动:绝对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18415969/

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