gpt4 book ai didi

html - html标签的边框和背景

转载 作者:太空宇宙 更新时间:2023-11-03 19:18:13 24 4
gpt4 key购买 nike

html { margin:0; padding:0; background-color:#006600; border-style:solid;  } /*Dark Green*/
body { margin:0; padding:0; background-color:#660000; border-style:dotted; } /*Dark Brown*/

<html>
<body>
test
</body>
</html>

为什么 html 标签的背景颜色扩展了整个窗口,但标签的边框样式仍然局限在正文框边框之外。

最佳答案

指定合适的高度和宽度应该可以解决您的问题。
尝试使用适当的高度和宽度值。


请参阅此链接:Understanding the HTML versus BODY Element in CSS

The html and body elements aredistinct block-level entities, in aparent/child relationship.
The htmlelement's height and width arecontrolled by the browser window.

The body element is (by default)position:static, which means thatpositioned children of it arepositioned relative to the htmlelement's coordinate system.

Inalmost all modern browsers, thebuilt-in offset from the edge of thepage is applied through a margin onthe body element, not padding on thehtml element.

希望您对自己的疑问有所了解。

关于html - html标签的边框和背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5444187/

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