gpt4 book ai didi

html - 为什么完整的背景图片适用于 body 而不是 CSS 中的 html?

转载 作者:行者123 更新时间:2023-11-28 02:40:49 24 4
gpt4 key购买 nike

我在 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 调用不会更新它但 body 会更新,这是没有意义的。

除了我正在使用的 Bootstrap 框架之外,其余代码都是空白的。

最佳答案

The rest of the code is blank except for the Bootstrap framework I'm using

……那是你的问题。

Bootstrap CSS 在 body 元素上设置背景颜色。

body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.42857143;color:#333;background-color:#fff}

source

这会覆盖您应用到 HTML 元素的任何背景。

设置 body { background: transparent } 会覆盖它。

关于html - 为什么完整的背景图片适用于 body 而不是 CSS 中的 html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47185504/

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