Style Sheets
  Home arrow Style Sheets arrow Page 3 - Creating Gradients for Individual Containe...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

Creating Gradients for Individual Containers with PNG Images
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-06-04

    Table of Contents:
  • Creating Gradients for Individual Containers with PNG Images
  • Creating gradients for several web page headers
  • Styling individual containers of a web document
  • Styling individual containers for a given web page

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Creating Gradients for Individual Containers with PNG Images - Styling individual containers of a web document


    (Page 3 of 4 )

    If you think that applying PNG gradients to all of the <h2> elements in the prior web page is a no-brainer process, then you’ll probably find that styling its respective containers is even easier to grasp, since this procedure is reduced to using the same CSS hack that you learned earlier, and then defining a brand new CSS class that will be tasked with decorating these containers.

    Now let me show you the definition of a brand new CSS class, which I’ll use later to style the corresponding containers of the previous sample web page.

    Here’s how this CSS class looks; pay close attention to its definition:


    .contbox{

    padding: 10px;

    margin-bottom: 10px;

    background: #fff url(bg.png) left top repeat-x;

    border: 1px solid #ccc;

    }


    /* use the * html CSS hack to render an alpha-based transparent background */

    * html .contbox{

    padding: 10px;

    margin-bottom: 10px;

    height: 100%;

    background: #fff;

    filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='bg.png',
    sizingMethod='scale');

    }


    In this particular case, I created a brand new CSS class, called “contbox,” whose primary function is to style all of the individual containers included in the sample web page that you saw with previous examples. It’s clear that I used the same CSS hack that was applied on prior occasions to display the pertinent PNG background images in a consistent way across different browsers, including Internet Explorer.

    That was very simple to understand, right? Essentially, all that I did was define a specific CSS class that will be responsible for adding fancy gradients to several containers of a web page by using a single transparent PNG graphic. Again, I’d like to highlight the advantages of using this approach, since those gradients are constructed by combining a unique PNG image that fades smoothly to transparency, and a solid background color.

    So far, so good. Having already showed you how to define a simple CSS class aimed at decorating the respective containers of the previous sample web page, the next thing that I’m going to do will consist of linking this CSS class to the corresponding structural markup. This will complete the demonstration of building eye-catching web page gradients using PNG images.

    To see how all the pieces are put together, please read the last section of this tutorial. It’s only one click away.

    More Style Sheets Articles
    More By Alejandro Gervasio


       · The previous tutorial explained how to build PNG-based gradients for headers of a...
     

    STYLE SHEETS ARTICLES

    - Using CSS3`s Border-Radius Property to Build...
    - Adding Semantic Meaning to Styled Code Block...
    - Styling Code blocks with CSS: Using pre HTML...
    - Building Rounded Corners with CSS3
    - Finishing a Casual Navigation Bar with CSS S...
    - Defining a Navigation Bar`s Hover State with...
    - Styling a Blog`s Links Bar with CSS Sprites
    - Creating an Artistic Blog Header with CSS Sp...
    - Defining the Active State of Menu Sections f...
    - Styling the Hover State of a CSS Sprite-Base...
    - Building CSS Sprite-Based Navigation Bars
    - Creating Framed Pictures with CSS
    - Using a CSS Shading Effect to Decorate Images
    - Decorating Images with CSS
    - Finishing a Drop-Down Menu with the Hover CS...







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 10 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek