如何在页面内容后面放置背景图片? [英] How to place background image behind page content?
本文介绍了如何在页面内容后面放置背景图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的网页上有一个背景图片。现在我想添加浮在其上的内容。下面的代码将内容放置在图像后面。如何纠正它?
I've got a background image on my webpage. Now I want to add content that floats over it. The code below places the content behind the image. How to correct it?
请注意,我借用了(并试图获得该效果)在此链接中讨论的背景图片: CSS-Only Technique#2
from: http: //css-tricks.com/perfect-full-page-background-image/
Note that I've borrowed (and I'm trying to get the effect) discussed in this link for background image: CSS-Only Technique #2
from: http://css-tricks.com/perfect-full-page-background-image/
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
<!--
#bg {
position: fixed;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
}
#bg img {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
min-width: 50%;
min-height: 50%;
}
-->
</style>
</head>
<body>
<div id="bg">
<img src="myimage.jpg">
</div>
<div id="mycontent">
...
</div>
</body>
</html>
推荐答案
只需将 z- index
为负值
Simply set your z-index
to a negative value
#bg{
z-index:-1;
}
这篇关于如何在页面内容后面放置背景图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文