我正在尝试使用CSS移动前景图像,因此它与背景图像重叠一点.我似乎无法让前景图像移动到任何地方,我只是无法弄清楚我做错了什么.谁能指出我正确的方向?看我的小提琴.
HTML:
<img src="http://image.tmdb.org/t/p/w1000/aUYcExsGuRaw7PLGmAmXubt1dfG.jpg" style="-webkit-mask-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,1)), to(rgba(0,0,0,0)))"
width="auto" height="400" class="backgroundImg">
<div class="frontImg">
<img src="http://image.tmdb.org/t/p/w150/2i0JH5WqYFqki7WDhUW56Sg0obh.jpg" class="" height="300" width="auto">
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
body{
background: black;
}
.background{
position: absolute;
left: 0px;
top: 0px;
z-index: -1;
}
.frontImg{
position: absolute;
left:200;
top:500;
z-index: 1;
}
Run Code Online (Sandbox Code Playgroud)
您缺少高度和宽度的单位(%,em,px等) .frontImg
body{
background:black;
}
.backgroundImg {
position:absolute;
left:0px;
top:0px;
z-index:-1;
-webkit-mask-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,1)), to(rgba(0,0,0,0)));
}
.frontImg{
position:absolute;
left:200px;
top:100px;
z-index: 1;
}Run Code Online (Sandbox Code Playgroud)
<img src="http://image.tmdb.org/t/p/w1000/aUYcExsGuRaw7PLGmAmXubt1dfG.jpg" width="auto" height="400" class="backgroundImg">
<div class="frontImg">
<img src="http://image.tmdb.org/t/p/w150/2i0JH5WqYFqki7WDhUW56Sg0obh.jpg" height="300" width="auto">
</div>Run Code Online (Sandbox Code Playgroud)
另外,您可以进行一些优化:您可以将css从样式属性移动到css文件,以获得没有任何内联css的干净html结构.
我认为你的CSS上有一个拼写错误 - 取而代之的.background是.backgroundImg.
| 归档时间: |
|
| 查看次数: |
500 次 |
| 最近记录: |