How could I style a div to like the below image?
Try this: To unskew the image use a nested div for the image and give it the opposite skew value. So if you had 20deg on the parent then you can give the nested (image) div a skew value of -20deg. @darthmaim's answer (below) to use a psuedo (before or after) to skew the inner border's should be the accepted answer.
You can use half triangle with the pseudo element.
.container {
padding: 20px;
background-color: #F8F8F8;
max-width: 200px;
}
.rectangle {
width: 200px;
height: 100px;
background-color: #003781;
position: relative;
}
.rectangle:after {
content: '';
position: absolute;
bottom: 0;
right: 0;
width: 0;
height: 0;
border-style: solid;
border-width: 0 0 25px 25px;
border-color: transparent transparent #F8F8F8 transparent;
}
<div class="container">
<div class="rectangle"></div>
</div>
Jsfiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With