<html> vs. <body> element in css

Summary

  • The html and body elements are distinct block-level entities, in a parent/child relationship.
  • The html element's height and width are controlled by the browser window.
  • It is the html element which has (by default) overflow:auto, causing scrollbars to appear when needed.
  • The body element is (by default) position:static, which means that positioned children of it are positioned relative to the html element's coordinate system.
  • In almost all modern browsers, the built-in offset from the edge of the page is applied through a margin on the body element, not padding on the html element.

重要的一点:html 的宽和高 由浏览器窗口控制

block-level elements which don't have a specific height applied to them automatically grow in height to accommodate their content. What happens when a height is applied? It depends on the value of the CSS overflow property

块级元素默认没有特别指定高度,根据包裹其中的内容自动增长高度,如果为其指定高度,接下来发生的事就要取决于 overflow 这个属性的值了。


html 元素 默认 overflow 熟悉为 auto,但是没有指定它的高,为什么会出现scrollbar?

The html element is a little bit special. Its height and width are governed by the window/frame it's in. When you increase your window width, the fixed width of the html element is increased; when you make the window taller, so increases the height of the html element.

观点来自于:

点击打开链接




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值