gpt4 book ai didi

不使用 url 的 CSS 背景

转载 作者:太空宇宙 更新时间:2023-11-04 13:52:56 26 4
gpt4 key购买 nike

有没有办法在 CSS 中包含背景而不使用 url()

例如,我不能这样做:

#blah {
background:url("either image or image data");
}

有没有一种解决方法可以实现相同的目的但不使用关键字“url”(禁止使用“url”一词。

最佳答案

您可以使用 <img>标记为背景图片,CSS 中不需要 URL。像这样:

HTML

<img src="image.jpg" class="bg">
<div id="page-wrap">
</div>

CSS

img.bg {
min-height: 100%;
min-width: 1024px;
width: 100%;
height: auto;
position: fixed;
top: 0;
left: 0;
}

@media screen and (max-width: 1024px) {
img.bg {
left: 50%;
margin-left: -512px;
}
}

有关更多信息和演示,请参见此处:http://css-tricks.com/perfect-full-page-background-image/

关于不使用 url 的 CSS 背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22102052/

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