Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
CSS based layouts are also extremely flexible, allowing for a lot of creative control that you might want to be consider including what's called a liquid layout. And that's what I want to do here. Currently this layout is more of the fixed layout. That means if I'm scaling the browser, my content is at a fixed position and doesn't scale with the browser and what I want to happen is I want this content to always be centered in the browser regardless of the size of the browser.
So, not only center the content but also I want this content to scale based on the size of the browser. So if I have the browser smaller, I want all of this content to be centered and then scaled down to about 70% of the browser. So that's the size of the Box that I want. If you scale down the browser or scale it up, it always going to take about 70% of the browser size. So again centering and then scaling is what I'm going to work on. So I'm going to close this browser and go into Dreamweaver.
And from here what I want to do is I need to center all of this content, I need to make sure it's centered. So all of this body content, I need to center. So I'm going to go to my CSS Styles panel, I'm going to go down to body, and I'm going to double-click on the body element. And from the Category area I'm going to choose Block. From here I'm going to change the Text-align to center. So that's going to center all of the body content.
In fact if I select OK, you will see sure enough it centers everything. So that's looking pretty good so far but I do have an issue with this paragraph text, which I need to fix. I would really like it to be kind sort of left aligned as opposed to centered. So that means I need to add it because if I look in my CSS Styles panel, there is no paragraph style, there is no P style. So that's what I need to add. So I'm go to my CSS Styles panel and down at the base of the panel, you will notice this little New CSS Rule icon.
You can just click on it. And that will bring up this New CSS Rule dialog box. So what I need to do is I need to redefine the p tag. So I'm going to Tag which is me just redefining an HTML element. And since my cursor was already in the paragraph area it automatically populates that with p. So this selector name will apply your rule to all of the p elements, which is just fine. That's cool. I'm going to select OK, and sure enough I get the opportunity to define this CSS Rule and really I'm going to go down to Block and for Text-align, I'm going to go ahead and left align it. I select OK.
It left aligns all of that text. This commonly might happen. It might shift other things because say for instance if you take this nav, I would really want this nav to be centered. But it shifted it to the left and it's because this is in a P tag. So I can remove any of that formatting I want using my Properties panel. I'm going to go to Format. You can see it has the p tag or the Paragraph style applied to it. Well, I can always change that to None and it's going to center that nav. Perfect! Now everything is centered, in place.
It's looking pretty good. But what I want to do now is focus on this Box. This content box is what I need to change now, so I'm go to Properties and I'm going to change the content element. In my CSS Styles panel, I'm going to go to content and I'm going to double-click on it. And for this Rule definition I'm going to modify two areas. I'm going to focus on the Box area and then we'll work on Positioning. For the Box area, I need to not necessarily have the Width 700 pixels but I want this to be a percentage.
So I'm going to type in 70 and then change pixels to %. So it's going to be 70%, the Width of the browser. But I also need to modify the Margin area. I don't want it to necessarily scale from the Top to the Bottom, so I need to un-check Same for all. But in the Margin area I want to change the Top to 0 and the Bottom to 0. So I don't want there to be any Margin at the top or at the bottom. But what I do need to modify is I need to make sure the Margin, which is the space between the Box and the browser.
I need this Margin area to always be automatically adjusting. So what I need to type in this Right input text field is auto, so it's going to automatically adjust depending on the Width of the browser. Same thing for the left side, I'm going to type in auto there. And in effect this is going to be roughly 15%, and this is going to be 15%. And then the other 70% is actually the content box. So that's looking pretty good, in fact I'll click Apply, and it does change it a little bit.
But I still need to modify one other area. So I'm going to go to Category, down to Positioning, and in here you can see that the Width does says 70%. But the Position says absolute, which is totally unnecessary. So I can actually remove that, just like that. In fact there is some other positioning elements that I can remove as well because I don't need this absolute positioning. I'm going to remove most of those fields, click Apply, and then we can see it center of the content. It's looking good so far, so I'm going to select OK.
And I'm going to go to File, and save this page. Then I'm go to File, and preview this in the browser. And here is the moment of truth. It does the center of the content, oh yes. It not only centers the content but it scales it. So it's always 70% of the browser. The left and right sides are both about 15%. And really it's working well. Regardless of what's sort of size monitor you are on, you are going to be able to read this content.
So again, CSS is a really effective way and a real flexible way to create a layout and modify a layout depending on what you are going for with your website.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.