Join James Williamson for an in-depth discussion in this video Defining fixed, elastic, liquid, and hybrid, part of Dreamweaver CS4 with CSS Essential Training.
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.
- Understanding XHTML and CSS fundamentals
- Understanding and implementing advances in typography
- Using the Code Navigator for faster CSS edits
- Styling form elements while maintaining accessibility
- Customizing the look and functionality of Spry widgets through CSS
- Controlling layout and positioning through styles
- Controlling CSS with the Properties Inspector
Skill Level Intermediate
Q: Is it possible to use CSS to create drop shadow effects over patterns and other backgrounds that aren't 100% white?
A: Try using the CSS3 drop shadow property, or use transparent PNGs as background images. A useful technique is detailed here: http://dev.opera.com/articles/view/css3-border-background-boxshadow/
The technique covered in the "CSS drop shadows" movie in the Dreamweaver CS4 with CSS Essential Training course will work if the drop-shadow file is prepared with a transparent background and saved as a 24 bit PNG file.
Q: While attempting to share assets between layers of a Fireworks file, as instructed in the Chapter 3 tutorial “Page creation and asset sharing,” an error message reads "Master page layers are not editable from other pages. Shared layers cannot be made a sub layer.”
A: This problem often occurs when attempting to edit or move a layer that is set as a master page layer. To avoid this error, switch to the master page and note the shared layers. Any editing to those layers must be done while on the master page.
Q: Is it possible to build a page using Dreamweaver CS4 Starter Pages, then use the CSS code in a site that was written using Visual Studio? In Chapter 2, the author states that the CSS must be embedded within Dreamweaver. Does that mean a Starter Page cannot be used withing a site built with another tool?
A: When the author states, "the CSS must be placed inside the page," he is referring to the creation of custom Starter Pages, in addition to the ones already included in Dreamweaver. Once the Starter Page is created, CSS can be placed as embedded styles or in an external style sheet, so it is possible to use Starter Pages with Visual Studio or another web design tool.
Q: In the "Preparing custom starter pages" video, the author’s screen shows the CSS Styles panel with listings displayed in an outline mode, connected by vertical lines. How can I get my CSS Styles panel to display this way? I am using a Mac, while the author uses a Windows machine. Is this a case where the difference is based on the specific operating system?
A: That is indeed one of the (minor) interface differences between the Mac and the PC. In the Mac version of Dreamweaver, the All view of the CSS Styles panel shows top-level CSS files or style tags with a small triangle beside them. They can still be explored or minimized by clicking on them to toggle them. They still show an "outline" view, just without the connecting lines. The functionality is not affected in any way.