I transformed my personal site into a magazine-style layout
See how I transformed my personal site into a magazine-style layout using just CSS shape-outside, floats, and a bit of Tailwind ✨ Text wraps beautifully around my images!
Everything I said
I'm redesigning my personal website. I know. Developers are always doing that, but I only do this once every several years, and this is what we're gonna be building today. Look at this. Look at this beautiful outline. Look at that. It follows the shape of this picture, and it looks super awesome. And then over on this side, it does the same thing. Even if we shrink it down a little bit, look at that.
It's wrapping and then, boop, it goes away when we run out of space. But this one still wraps all the way around that image and then floats down there if we need to. When I was looking for design inspiration, I started looking on Pinterest for newspaper and magazines, and I came across this, and I thought, "Oh, that's pretty cool.
I really like that. Like, look at that." So I went down the rabbit hole to figure it out. And what I found is a CSS property that I did not know about called shape-outside. We're going to define a polygon with percentage-based measurements instead of pixel-based measurements. For shape-outside, you must float. So we're gonna float soccer to the left, and we're gonna float the stage picture to the right, and then hopefully, the content will end up in the middle.
We floated both images out, and now the content ends up in the middle, but you'll see it does have a straight edge, and that is because if we put a, uh, if we put a border on this guy, you'll see that is the box. That is the margin. That is the outside shape. That's the margin box, as they call it. So that's a problem. That's not what we're after.
What I do want is shape-outside. There we go. Look at that. So you'll see we still have the image border, so we haven't actually changed the shape of the image, but what we're communicating to, uh, the browser is, "Hey, use... Instead of using that hard right edge, use this polygon that I passed in." And look at that.
Now, we have this nice little edge going on, and let's remove the borders 'cause that was for demonstration, and we don't need that anymore. That looks pretty good.