[英]Why did a full background image work for body but not html in CSS?
我在CSS中執行了以下操作,但它沒有更改網頁:
html {
background:url("image.jpg") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
但是后來我做了下面的代碼,背景改變了我想要的樣子:
body {
margin:0;
padding:0;
background:url("image.jpg") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
為什么html調用不會更新它,但是正文會更新,這是沒有道理的。
除我使用的Bootstrap框架外,其余代碼均為空白。
除我使用的Bootstrap框架外,其余代碼為空白
……那是你的問題。
Bootstrap CSS在body元素上設置背景色。
body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.42857143;color:#333;background-color:#fff}
— 來源
這涵蓋了您應用於HTML元素的所有背景。
設置body { background: transparent }
會覆蓋它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.