I am trying to create a background for a sections with 2deg angle.
I am not sure how this can be done, I tried to make it with ::after element, but had some trouble with the width.
Also there are 2 other rectangles (pink) at the corners of the main section which they are also having an angle and the responsive part is that while the screen is getting smaller, these should shrink until they disappear.
In this image it looks more clear what I mean. The view port is in the green area.
In CSS there is rarely an only way.
The clipping path is one option.
The link I posted uses a simple rotation transform, but the get the skew effect with the angled sides, you could use a 3D transform with the same method.
If I understand what you are trying to achieve, there are quite a few different ways to approach it. I’d probably use three separate SVGs for each of the rectangles, and then embed them in your CSS as a stack of background-images.
I’ve set an arbitrary height on the container. The background-positions for all layers are currently set to ‘center top’ but you can align them each to left, right or center by providing three sets of background-positions separated by a comma. The order corresponds to the background-image order.
The SVGs will stay sharp and scalable and it’s pretty easy to see where the precise 2 degree rotation is set.