Two Column Layout, but the other one goes to edge.
Hi everyone, may I ask the best way to make a layout like this responsively?
The red square will be an image.
The red line indicates the container of the site. But the image should go way to the edge of the view port.
Thank you for the response.
6 Replies
TLDR; The content should be inside the container but the image should span to the right edge
Use relative positioning + negative margin on the image container.
Example:
With the tools available nowadays like grid this solution is kind of hack imo
But also depends on the project size and use case
Setting up a grid system like this could do it but if it’s a small project , I may instead use a pseudo element for the image
Kevin Powell
YouTube
A new approach to container and wrapper classes
The wrapper or container is probably the most common design pattern around, but after coming across an article by Stephanie Eckles looking at how we can use a grid to emulate a container, and have simple breakouts — https://smolcss.dev/#smol-breakout-grid — I had an idea of how we could do this to completely drop the idea of containers, and then...
Oh, neat! That is indeed a much more elegant solution. Updating my previous answer:
If you want to stick to the naming concept of grid-lines, you could create another grid-line-name of [center-line] min(100% - (var(--padding-inline) * 2), 100% / 2; that way you could over-engingeer this correctly and change .image-section { grid-column: center-line / full-width-end