[英]why setting the height of the body to 100% sets automatically the width to 100%?
我注意到將html和body高度設置為100%,body的寬度似乎會自動設置為100%(即使在CSS規則中沒有出現),為什么呢?
<html>
<head
<title>full screen</title>
<style>
html, body{
margin: 0;
height: 100%;
background-color: rgb(200,50,50);
}
</style>
</head>
<body>
</body>
</html>
將這些元素的高度設置為任何值(甚至根本不設置)都不會更改其寬度,由於它們是block
元素,默認情況下為100%。
您可以通過檢查瀏覽器中的任何HTML頁面並查找屬性display: block;
來驗證這一點display: block;
,由user agent stylesheet
(您的瀏覽器)在這些元素中定義。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.