Home arrow Style Sheets arrow Page 3 - 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 - Defining a CSS file for creating liquid web page layouts
(Page 3 of 4 )

In the previous section, you learned how to build a basic reset CSS file for assigning default styles to certain common elements of a web document. Since this file is the first module of the CSS framework that I’m currently developing, it’s time to create its second component. It comprises a CSS file that will be tasked with building several liquid web page layouts.

Of course, there are many approaches that can be implemented for building these types of layouts pretty quickly. In this case I’m going to use a basic schema that will allow us to define generic containing areas, title sections and logically primary columns across a web document with extreme ease.

Now that I have explained how this second CSS file is going to function, please take a close look at its definition, which is shown below:


#header,#footer{

padding: 10px;

background: #9cf;

}

#navbar{

padding: 10px;

background: #dcdcdc;

}

#navbar li{

display: inline;

}

#mainwrapper{

clear: both;

height: 100%;

overflow: hidden;

background: #eee;

}

#mainwrapper .leftcol{

position: relative;

float: left;

}

#mainwrapper .rightcol{

position: relative;

float: right;

}

#leftbar{

width: 20%;

}

#centerbar{

width: 80%;

}

/* section title */

.title{

font: bold 12pt Arial, Helvetica, sans-serif;

color: #036;

background: #9cf;

margin: 0;

padding: 10px;

}

/* generic box */

.box{

background: #fff;

border: 1px solid #ccc;

margin-bottom: 18px;

}

/* headers for containing box */

.box h2{

font: bold 14pt Arial, Helvetica, sans-serif;

color: #039;

margin: 0 0 18px 0;

}

.box h3{

font: bold 13pt Tahoma, Arial, Helvetica, sans-serif;

color: #039;

margin: 10px 0 18px 0;

}

.box h4{

font: bold 12pt Tahoma, Arial, Helvetica, sans-serif;

color: #039;

margin: 0 0 18px 0;

}

.box h5{

font: bold 11pt Tahoma, Arial, Helvetica, sans-serif;

color: #039;

margin: 0 0 18px 0;

}

.box h6{

font: bold 9pt Tahoma, Arial, Helvetica, sans-serif;

color: #039;

margin: 0 0 18px 0;

}

/* generic container */

.content{

padding: 10px;

}

p{

font: normal 8pt Verdana, Arial, Helvetica, sans-serif;

color: #000;

margin: 0 0 18px 0;

}


Now that you have seen how the above layout CSS file has been created, things are getting much more interesting. As you can see, the file in question not only redefines the style of common web page elements, like paragraphs and headers, but it declares a few basic CSS classes that can be used for creating a liquid two-column layout in a straightforward way.

The respective side and main columns of the web document have been styled via the “#leftbar” and “#centerbar” selectors, but aside from these, there are three additional classes, called “title,” “box” and “content” respectively, that allow you to build entire containing boxes and title sections pretty easily.

Of course, as I mentioned before, there are many other approaches that can be utilized for building generic containers for a concrete web page; however, the file that I defined above is quite simple to code and read, even for inexperienced web designers.

At this stage, assuming that you have already grasped how the previous CSS file does its thing, it’s time to set up an introductory example to test the capabilities of this CSS framework, which is now composed of two source files.

The purpose of the example in question will be demonstrating how simple it can be to create a two-column liquid web page layout by using the two CSS files coded previously.

You can learn the complete details of this brand new example if you read the next few lines. It’s only one click away.


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