Watching:

Defining fixed, elastic, liquid, and hybrid


show more Defining fixed, elastic, liquid, and hybrid provides you with in-depth training on Web. Taught by James Williamson as part of the Dreamweaver CS4 with CSS Essential Training show less
please wait ...

Defining fixed, elastic, liquid, and hybrid

When creating a new page based off of a starter page, you can choose from several layout options like 1, 2 or 3 column layout, and whether or not the page should have headers or footers. In addition to these specific element choices, you also need to choose which type of layout you want. starter page come in four types. We have fixed, elastic, liquid, and hybrid. In this movie, we'll explore those layout choices and when it's appropriate to use one over another. We are going to start by looking at a fixed layout, and I have the fixed.htm page open.

So with the fixed layout, these have column widths that are set to a specific pixel size, and they are not going to change or resize based on either changes in screen resolution, browser window resizing, or font size changes. So I'm going to go ahead and demonstrate that by previewing this on my browser. Now, I'm going to preview this in Firefox. So some of the things that I'm going to be doing here, like changing font sizing, it's specific to Firefox, so if you are using a different browser, be sure to look up in its options or menus to see how you would do it within your browser. Now, if I resize the browser window, I notice that my layout doesn't change at all.

Now, it's centered to the viewport, so it's staying centered the whole time, but you will notice that the widths of my columns aren't being affected at all. Now, what if I increase font size? Well, I'm going to go up to View > Zoom. I can also set an option to make sure that I'm only changing the text size and not zooming the entire layout. So I want to make sure that's turned on in Firefox. Again, if you are using a different browser, be sure to see how you can change your font size up or down if you are doing this little example along with me. So if I increase the size of my font, notice that although areas are getting taller or skinnier, because the height isn't fixed, notice that the width of the columns is staying exactly the same.

So it doesn't matter if I resize my browser window or increase and decrease the size of my text, my columns are staying exactly the same size and the width of my layout is staying exactly the same size. So a fixed layout is really great for any time that you need fixed layouts, or you are targeting a specific browser window, or you are targeting a specific resolution. So I'm going to go ahead and close Firefox, come back into Dreamweaver, and I'll close the fixed design. Now, the next one I want to open up is the elastic file, so that we can see an elastic layout. Elastic layouts have column widths that are set to ems.

Now, an EM is a relative unit of measurement based on the size of the font. So resizing the browser won't really change the layout, but the layout is going to react to any adjustments that we make in text size, and that of course can be set by the client within the browser. Now, this layout is ideal for accessibility driven layouts or layouts that are designed for smaller screen sizes. So I'm going to go ahead and preview that in my browser, and again, changing the browser size doesn't really affect the layout at all, other than just moves where it's centered.

But watch what happens when I increase or decrease the size of the text. So if I increase the size of the text, notice that the sidebar and the main content region are getting larger to accommodate that text. If I shrink the size of the text, notice that the main content regions and the sidebar regions are shrinking down as well. So this is a nice scalable layout based on font size. So this layout is great for accessibility driven sites, layouts for smaller screen sizes, or layouts for different devices where the screen size is going to change based upon the device that you are using.

So I'm going to go ahead and close that and we'll close our elastic file. Next up, I want to take a look at the liquid layouts. Liquid layouts have column widths that are set to percentages of the total browser or viewport width. So these layouts are going to resize based on browser size, and they are really good for situations where there is no one specific target resolution, or in environment where the viewport size is going to change frequently. So I'm going to go ahead and preview that in my browser. This time I notice that increasing or decreasing the font size doesn't really change the width at all, and it pretty much stays the same.

But I did notice that the width of this was different from my other pages right off the bat, because it's based off of a percentage. So if I resize the browser, notice that the page widths are changing as well. Now, there is something that you need to be aware of here. When you set something like a sidebar to a percentage, let's say you make it 20 or 30%. When you size that down far enough, you are going to finally eventually get to a part where the content can't fit within that percentage anymore. When you do that, you are going to see something like this, where we have content that's sort of overlapping each other. Now, there are certain ways to deal with that, such as setting up a minimum width for our sidebar.

But that is something you need to be aware of if you are going to use a liquid layout. Next up, let's take a look at a hybrid layout. Now, these are really interesting. Hybrids layouts are a combination of elastic and liquid layouts. In a hybrid layout, certain columns may be based on percentages, while others could be based on text size. In this particular example, our content region is based off of a percentage, where the sidebar is based off of an em. This type of layout is usually used to keep smaller columns from shrinking too much as the screen is resized, while allowing the larger columns to scale based upon the available screen size.

So let's check that out. So if I preview this in my browser, I can see that resizing the browser allows the main content to shrink or expand, but that the sidebar stays exactly the same. But notice that if I increase the font size, the sidebar changes along with that. So increasing or decreasing the font size gives me more or less room for the sidebar, where changing the browser window size affects the main content only. So it's a really nice flexible layout that offers a lot of functionality.

It's a little bit more difficult to maintain, because you have to keep track of all those percentage values and EM values and know exactly what they are pertaining to. Now, I do want to mention that in addition to these four layout choices, there are several absolutely positioned layouts to chose from. Absolutely positioned elements are removed from normal document flow and they're positioned based on values that you give to either top, left, right, or bottom positions. Since these absolutely positioned elements don't react to the elements around them, they are typically only used for static fixed size layouts.

Now that we have examined the different types of layouts available, we'll explore opening a starter page and customizing the CSS for your own specific usage.

Defining fixed, elastic, liquid, and hybrid
Video duration: 6m 3s 12h 7m Intermediate

Viewers:

Defining fixed, elastic, liquid, and hybrid provides you with in-depth training on Web. Taught by James Williamson as part of the Dreamweaver CS4 with CSS Essential Training

Subject:
Web
Software:
Dreamweaver
Author:
please wait ...