Home arrow Style Sheets arrow Page 3 - Using a Background Grid to Assist Web Page Layout
STYLE SHEETS

Using a Background Grid to Assist Web Page Layout


Welcome to the seventh and final installment of a series covering fundamental design principles as applied to web layout creation. This series uses numerous code samples to show you how to implement such design concepts as the Golden Ratio and the Rule of Thirds to construct several professional-looking web page designs that will be visually appealing to your visitors.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
August 06, 2009
TABLE OF CONTENTS:
  1. · Using a Background Grid to Assist Web Page Layout
  2. · The background grid for a Rule of Thirds web page
  3. · Displaying the background grid on the web page
  4. · Completing the sample web page layout

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Using a Background Grid to Assist Web Page Layout - Displaying the background grid on the web page
(Page 3 of 4 )

Before I start showing you how to transform the grid image created in the previous section into a visual guide that will be displayed on the web page, it’s fair to clarify that this approach isn’t mine. The idea of using an image as a background grid was originally conceived by Khoi Vinh and you may want to take a look at his site here (http://www.subtraction.com/2004/12/31/grid-computi) to see a nice usage of his grid.

Having said that, it’s time to code the corresponding CSS styles that will be responsible not only for creating a fixed three-column web page layout, but for assigning the grid image that you saw previously to the page’s <body> element.

These CSS styles will be defined in the following way:

body{

padding: 0;

margin: 0;

background: #eee url(grid.gif) center top repeat-y;

}

#container{

width: 900px;

margin: 0 auto;

}

#header{

height: 100px;

padding: 0 10px 0 10px;

}

#sidebar{

float: left;

width: 280px;

padding: 0 10px 0 10px;

}

#extrabar{

float: right;

width: 280px;

padding: 0 10px 0 10px;

}

#content{

margin-left: 300px;

margin-right: 300px;

height: 302px;

padding: 0 10px 0 10px;

}

#footer{

clear: both;

height: 100px;

padding: 0 10px 0 10px;

}

h1,h2,p{

margin: 0;

}

As you can see, the set of CSS styles defined above are tasked with building a simple web page layout which is composed of three primary columns, identified as “sidebar,” “content” and “extrabar” respectively. Each of these columns has been assigned a width of 300px, aligning the whole design with the Rule Of Thirds. However, the most relevant thing to note here is the following rule:

body{

padding: 0;

margin: 0;

background: #eee url(grid.gif) center top repeat-y;

}

Despite its ease, this rule is truly powerful; it tells the browser to display the grid image created in the previous segment across the whole web page, as a background grid. Now it’s much easier to align elements on the page, since the background image acts like some of the grids available in any graphic editing program.

Pretty nice, right? At this point, you hopefully understand how to use a simple GIF or PNG image as a helpful background grid, which can be displayed on a web document for aligning purposes. However, the CSS styles coded above would be incomplete if they weren't linked to the document’s markup.

Therefore, in the section to come I’ll be performing this task, so you can see more clearly how the background grid can be utilized for placing different elements within the web page in perfect harmony.

Now, click on the link below and read the following segment.


blog comments powered by Disqus
STYLE SHEETS ARTICLES

- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...
- CSS3 Animated Image Gallery: Transitions
- CSS3 Properties: Fixed Heights with box-sizi...
- CSS3 Properties: Altering Strokes and 3D Eff...
- CSS3 Properties: Text-Stroke
- CSS3 Transitions: Width and Height Properties
- Creating a Drop Down Menu in CSS3
- Intro to CSS Transitions

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials