gpt4 book ai didi

html - css 样式的两个背景可能吗?

转载 作者:搜寻专家 更新时间:2023-10-31 08:22:06 25 4
gpt4 key购买 nike

我有一个使用具有此属性的 css 样式文件的网页:

body { 
background: #7a9c12 url(images/main_background.jpg) top center no-repeat;
color: #bbb;
font: 12px/14px helvetica, arial,Sans-serif;
}

如您所见,此代码仅将背景图像放在 div 正文的顶部中心。但是,我也需要在 body 标签的底部中心有一个背景图片,我该怎么做呢?谢谢!

最佳答案

如果您不使用 CSS3,一个选项是在您的 html 上分层背景图像。和 body标签:

html {
background: #7a9c12 url(images/main_background_top.jpg) top center no-repeat;
}

body {
background: url(images/main_background_bottom.jpg) bottom center no-repeat;
}

只需确保只对 html 应用纯色背景色即可background 属性,否则你将覆盖图像并且只看到 body背景图片。

关于html - css 样式的两个背景可能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3597406/

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