I want sections with content in a trapezoid div
but I don't know how to start or what the best way is to achieve my goal:
I had come across this solution but there isn't much info for me to understand CSS3 Transform to Trapezoid
HTML
<div class="section">
<p>content here</p>
</div>
Here is a way to create a trapzoid like div. This uses the ::before and ::after pseudo elements
Responsive? I could just hack my way trough a css solution but I'm going to recommend svg
How does it work? SVG is responsive by design so it will always scale to its container.
Added the preserveAspectRatio="none" so the svg scales in all directions.
The properties position:relative; and position:absolute; are for letting you put the svg in the background so content can go on top of its shape.
Since the shape is designed with inside a viewBox of 100 100 and the points of the shape range from 90-100 then there is a always a 10% gap at the bottom and top.
The triangle at the top of the shape will always be 10% of its container basically. That's why we set the top:10% and bottom:10% of the .trap-content class.