Closed Hecsall closed 10 months ago
My bad, with the class on the <picture>
tag the image was too high up, and after further testing, I noticed a piece of CSS that was not documented on the readme.
The readme writes:
.jarallax { position: relative; z-index: 0; } .jarallax > .jarallax-img { position: absolute; object-fit: cover; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; }
You can include it from /dist/jarallax.css.
So I just copy-pasted that block of CSS guessing that it was all it takes to use the picture tag, then I found this example https://codepen.io/_nK/pen/VwxpPoz where there is an added selector for the <img>
tag that fixes some styling:
.jarallax-img img {
position: absolute;
object-fit: cover;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
Without that block, with some image sizes, you could find white space inside jarallax below the image. See the issue inside this Codepen https://codepen.io/Hecsa/pen/zYmOxBg, when the 1920x600 image is visible, scrolling up and down reveals a white area between the image and the red block.
Confirmed!
Issue description:
I think the documentation about
<picture>
tags is slightly wrong, trying the example code from the readme leaves the image with a white area (the body background) on the side.Probably the correct usage, correct me if I'm wrong, is with the
jarallax-img
class on the inner<img>
tag and not on the<picture>
tag.Version used:
Latest npm release
Code to reproduce the issue
You can see an example here https://codepen.io/Hecsa/pen/WNgVEby