gpt4 book ai didi

html - 2 种背景的 CSS 最佳方法?

转载 作者:太空宇宙 更新时间:2023-11-03 22:05:00 25 4
gpt4 key购买 nike

我有一个设计,在背景的前 25% 部分有一些图像,然后它只是一个简单的渐变,我可以为其余部分重复。

将图像放在顶部,然后用渐变填充页面其余部分的最佳方法是什么?

我采用了这种方法:

html{
background: #cac2ac url("../img/body-bg.gif") repeat-y 50% 0;
}

body {
text-align: center;
font-family: Arial;
line-height: 1;
width: 100%;
background: transparent url("../img/body-img-bg.jpg") no-repeat 50% 24px;
}

但是在代码的一种实现中,HTML 的背景图像没有出现?

有什么帮助吗?

最佳答案

与所说的相反,您可以拥有html的背景。

您的方法差不多了,尝试使用 height: 100%min-height: 100%

http://jsbin.com/omikuy

html, body {
margin: 0;
padding: 0;
}
html {
background: #cac2ac url("../img/body-bg.gif") repeat-y 50% 0;
height: 100%;
}
body {
min-height: 100%;
text-align: center;
font-family: Arial;
line-height: 1;
width: 100%;
background: transparent url("../img/body-img-bg.jpg") no-repeat 50% 24px;
}

关于html - 2 种背景的 CSS 最佳方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7162133/

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