gpt4 book ai didi

html - img 表现得像背景图片?

转载 作者:太空狗 更新时间:2023-10-29 13:31:11 26 4
gpt4 key购买 nike

我在页面上有一个物理图像..

<img src="image.png" alt="image-name" />

不过我希望它表现得好像它是 body 背景图像一样..

body{
background: url(image.png) no-repeat center top;
}

即在浏览器看不到它的情况下居中,所以如果它比浏览器等更宽则没有滚动条?

这可能吗?

最佳答案

是的,这是可能的,你可能必须做这样的事情:

CSS

#your-image {
position: absolute;
z-index:1;
}
#container {
position: relative;
z-index: 2;
}

HTML

<body>
<img id="your-image src="" alt="">
<div id="container">
<!-- All your content goes there -->
</div>
</body>

关于html - img 表现得像背景图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13416668/

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