Advanced CSS Layouts

Article Layout Solution

Jen Kramer

Jen Kramer

Advanced CSS Layouts

Check out a free preview of the full Advanced CSS Layouts course

The "Article Layout Solution" Lesson is part of the full, Advanced CSS Layouts course featured in this preview video. Here's what you'd learn in this lesson:

Jen reviews a possible solution to the article layout exercise.


Transcript from the "Article Layout Solution" Lesson

>> Jen Kramer: So first thing to do when you're working with this is to take a look at the structure of your HTML. So you'll know exactly what kind of selectors you're going to need to form. And so one of the things that I did for you here is I put an ID of the inside on the body tag here, okay?

So that you have a little handle. It could very well be that you wind up with articles in the sides, other places and other documents. But this happens to be the one associated with the inside page, right? So when you scroll down to the main content, you see we have our main tag again.

We have an article. There's the article. Blah, blah, blah, blah, blah. We have on the side tends what people are saying about the book, there's our side, okay? And so that's what we have to work with. Our main tag is going to be what? The main tag becomes what?

>> Speaker 2: Flex box.
>> Jen Kramer: Our flex container, yeah, the parent. And then the article and the aside become what?
>> Speaker 2: The items.
>> Jen Kramer: They're the flex items, right, the children. So then we can go ahead over here and write our CSS right here. Do I need to change anything with main here?

This very first main. Do I need to change anything?
>> Jen Kramer: Nope. That's exactly what we need, right? And then down here, in our big logic statement here, what do we just need to do? Add inside article and inside aside. That's all we need to do, okay? And then down here when we get to the media queries, what we need to do is figure out what we're going to do for widths.

This is what I did. I just worked with the columns that I had in each of those dimensions. I decided I would just stay with those columns. You could have changed the number of columns that you had for the inside pages if you wanted to. That would certainly be one way to approach the solution.

But I just said, well, we're working with 11, how about 7 and 4, okay? And then when we got down to 950 and we're at 14, then I said, okay, how about 10 and 4? And then when I got down here to 1,200 pixels, I said, well, how about 12 and 4?

And technically speaking, I've repeated myself over and over again for the inside aside. But again, for documentary purposes, that sort of helps you understand the math and how it's all fitting together, okay? So that's how I put together my answer. Your answer may be different. You may have had different numbers of columns.

I would be cool with that as long as proportionally speaking, the page looks right. A fat area for your content, a skinny area for your article.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now