我需要在我的网站上添加背景图片。但是当我使用
时background-image:url('path_to_image');
但这来自我的容器类?如何在容器类后面制作图像?
答案 0 :(得分:1)
请看一下我的样本:
HTML:
<div class="container">
<div class="background">
</div>
<div class="infoContainer">
<input type="text" /><br/>
<label>Hi How are you</label>
</div>
</div>
CSS:
.container {
height: 500px;
width: 200px;
z-index: 2;
color: #fff;
}
.background {
width: 200px;
height: 200px;
background-image: url('Images/index.jpg');
position: absolute;
z-index: 1;
}
.infoContainer {
position: absolute;
z-index: 2;
padding: 5px;
}
输出
答案 1 :(得分:0)
尝试将其添加到正文
body {
background-image: url('path_to_image');
}
答案 2 :(得分:0)
<body background="image_path">
If you have a static page
OR add style to your body tag
<body style="background-image:url('image_path');">