Home arrow Style Sheets arrow Page 4 - Building a Simple CSS Framework
STYLE SHEETS

Building a Simple CSS Framework


The ability to reuse blocks of code is a blessing and a time saver to programmers everywhere. Web sites are too distinctive to allow you to do very much of this, right? Wrong. You can build a CSS framework to give you the flexibility you need, and use the time you save for the parts of your project that matter most. This five-part series shows you how.

Author Info:
By: Alejandro Gervasio
Rating: 4 stars4 stars4 stars4 stars4 stars / 9
February 19, 2009
TABLE OF CONTENTS:
  1. · Building a Simple CSS Framework
  2. · Creating a simple reset style sheet
  3. · Defining a CSS file for creating liquid web page layouts
  4. · Building a two-column liquid web page layout

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Building a Simple CSS Framework - Building a two-column liquid web page layout
(Page 4 of 4 )

If you’re like me, then you want to see how the CSS framework developed in the previous section can be implemented in a truly useful way. With that idea in mind, below I coded a sample (X)HTML file that utilizes the framework to build a primitive web document. The document is composed of two primary columns, as well as the usual header and footer sections. Here it is:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Liquid layout 2 columns</title>

<link rel="stylesheet" type="text/css" href="reset.css" />

<link rel="stylesheet" type="text/css" href="liquidlayout_2cols.css" />

</head>

<body>

<div id="header">

<h2>This is the header section of the web page</h2>

<p>Contents for header section go here. Contents for header section go here. Contents for header section go here. Contents for header section go here.</p>

</div>

<div id="navbar">

<h2>This is the navigation bar of the web page</h2>

<ul>

<li><a href="#">Link 1</a></li>

<li><a href="#">Link 2</a></li>

<li><a href="#">Link 3</a></li>

<li><a href="#">Link 4</a></li>

<li><a href="#">Link 5</a></li>

<li><a href="#">Link 6</a></li>

</ul>

</div>

<div id="mainwrapper">

<div id="leftbar" class="leftcol">

<div class="box">

<div class="title">SECTION TITLE</div>

<div class="content">

<h2>Header goes here.</h2>

<p>Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here.</p>

</div>

</div>

<div class="box">

<div class="title">SECTION TITLE</div>

<div class="content">

<h2>Header goes here.</h2>

<p>Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here. Contents for left column go here.</p>

</div>

</div>

</div>

<div id="centerbar" class="leftcol">

<div class="box">

<div class="title">SECTION TITLE</div>

<div class="content">

<h2>Header goes here.</h2>

<p>Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here.</p>

<p>Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here.</p>

<p>Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here.</p>

</div>

</div>

<div class="box">

<div class="title">SECTION TITLE</div>

<div class="content">

<h2>Header goes here.</h2>

<p>Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here.</p>

<p>Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here.</p>

<p>Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here. Contents for center column go here.</p>

</div>

</div>

</div>

</div>

<div id="footer">

<h2>This is the footer section of the web page</h2>

<p>Contents for footer section go here. Contents for footer section go here. Contents for footer section go here. Contents for footer section go here. Contents for footer section go here.</p>

</div>

</body>

</html>


In this particular case, the above sample file illustrates how to use the CSS files that comprise this framework to build a two-column liquid web page layout. As you can see, the framework permits us not only to construct the general layout very easily, but also allows us to include containing areas and title sections within the web document with minor hassles.

The previous example would be incomplete if I didn't complement it with a screen shot that shows the visual presentation of the recently-created web page, so here it is:



That looks pretty good, right? Taking into account that building a web document layout like the one shown above only required coding two simple, straightforward CSS files, the end result is pretty satisfactory.

And as a corollary to this tutorial, feel free to introduce your own improvements to the CSS framework developed before, so you can expand its existing functionality and your web design skills.

Final thoughts

In this first part of the series, I used a few basic examples to help explain how to create a reusable CSS framework, which can be used for building several liquid web page layouts very quickly. As you saw earlier, the whole development process demanded only that we code two simple CSS files.

In the upcoming chapter, I’ll be extending the functionality of the CSS framework to provide it with the capacity for constructing three-column liquid web designs. Thus, now that you know what to expect from the next article, don’t miss it!


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

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 9 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials