Utilizing the ::before
pseudo element was my initial approach. However, I encountered difficulty in positioning it below the main element, resulting in a slight loss of space.
Unfortunately, my attempt at using ::before
was quite unsuccessful. Furthermore, there were some peculiarities when using transform, especially noticeable when applying a background color on the element and viewing it on a wide screen.
Instead of struggling with this issue, I recommend using an SVG to achieve the desired slant effect. I did encounter a strange gap between the svg
and div
, but I managed to work around it by adjusting the positioning.
Feel free to adjust the values to customize the slant to your preference, keeping in mind that it may appear differently based on the screen width.
#footer {
position:relative;
overflow:hidden;
}
svg {
width: 100%;
fill: green;
max-height: 50px;
position:absolute;
top:0;
}
#footerContent {
margin-top:49px;
height: 100px;
background: orange;
}
<div id="footer">
<svg viewBox="0 0 100 20" preserveAspectRatio="none">
<polygon points="0,20 100,20 100,0" />
</svg>
<div id="footerContent"></div>
</div>