I need to create a slope/angled element, so I tried skew()
transform. Inside this element I have an image which I want to cover the whole area of parent element, but when I applied skew()
to image to make it straight, the image is not fully covered. I know I can use scale()
transform to cover the image but thats blur my image. What I am looking for is below image.
Is there any another way to do this?
* {
box-sizing: border-box;
margin: 0;
}
.container {
display: flex;
overflow: hidden;
flex-wrap: wrap;
margin: 0 -30px;
}
.container a {
border: 3px solid;
transform: skew(-30deg);
width: 20%;
overflow: hidden;
}
.container img {
max-width: 100%;
display: block;
transform: skew(30deg);
}
<div class="container">
<a href=""><img src="http://via.placeholder.com/350x150"></a>
<a href=""><img src="http://via.placeholder.com/350x150"></a>
<a href=""><img src="http://via.placeholder.com/350x150"></a>
<a href=""><img src="http://via.placeholder.com/350x150"></a>
<a href=""><img src="http://via.placeholder.com/350x150"></a>
</div>