I want the image to go all over this element, but I can't figure it out on how to accomplish this.
I am trying to achieve this layout:
But right now, I am stuck at this point:
I'm using codepen to test it, but I will post my code here:
HTML:
<div class="box">
<img src="https://source.unsplash.com/random" alt="" class="img-fluid h-100 w-100">
</div>
CSS:
.box{
margin: 50px 20px;
width: 200px;
height: 200px;
position: relative;
}
.box::after{
background-image: url("https://source.unsplash.com/random");
background-size: cover;
content: "";
border-radius: 20px;
width: 100%;
height: 100%;
position: absolute;
top: 0;
right: -90%;
z-index: -1;
transform-origin: top right;
transform: skew(-30deg, 0deg);
}
Any help or tip would be appreciated.
I was thinking about use mask or maybe a wrapper with z-index, but I am totally stucked.
I would also need the image to stay in the normal positon (not skewed), but that is not necessary at the moment.
Here's the link to the codepen that I'm using to solve this: https://codepen.io/jonathanyont/pen/yLGOebW?editors=1100
You need to skew the wrapper, set
overflow: hiddenon it and then unskew the image inside using the same angle as on the parent multiplied with-1.Like this: