Reputation: 57982
I've been working on a slider in JavaScript, and I've been adding images as backgrounds like so:
<img class="slide-bg" src="path/to/some/photo.jpg" />
CSS:
.slide-bg {
position: absolute;
filter: blur(3px);
-webkit-filter: blur(3px) grayscale(20%);
z-index: -3;
display: block;
margin: 0;
padding: 0;
}
This code, for some reason, yields this result:
Everything is great when I don't have position: absolute
, but I need to have that so I can apply z-index
and have the slide-content actually fit on top of the image. Without position: absolute
it yields this result:
Upvotes: 0
Views: 73
Reputation: 918
Add top:0;
to your css
.slide-bg {
position: absolute;
filter: blur(3px);
-webkit-filter: blur(3px) grayscale(20%);
z-index: -3;
display: block;
margin: 0;
padding: 0;
top:0;
}
Upvotes: 2