Style Sheets
  Home arrow Style Sheets arrow Page 2 - Creating Angled Corners with Transparent B...
IBM developerWorks
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  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
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 Angled Corners with Transparent Background Images
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2008-02-05

    Table of Contents:
  • Creating Angled Corners with Transparent Background Images
  • Review: building rounded corners by using a transparent background image
  • Building angled corners by using a single transparent background image
  • Seeing the angled corners effect in action

  • 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

    AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th -1:00PM EST. Register Today!

    Creating Angled Corners with Transparent Background Images - Review: building rounded corners by using a transparent background image


    (Page 2 of 4 )

    Before I proceed to demonstrate how to build some appealing angled corners for certain elements of a sample web page, I’d like to list the complete source code corresponding to the hands-on example that you learned in the previous tutorial of the series. As you’ll certainly recall, it was created to display some basic rounded corners on all of the <h2> headers contained in a primitive web page.

    The CSS styles and structural markup of the web page in question were initially defined in the following way:


    <!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>

    <title>Sample web page with rounded corners (transparent background image)</title>

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

    <style type="text/css">

    body{

    padding: 0;

    margin: 0;

    background: #ccc;

    }

    h1{

    padding: 5px;

    margin: 0;

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

    color: #000;

    }

    h2{

    padding: 7px 5px 8px 5px;

    margin: 0;

    background: #6cf url(rounded_corners_transp.gif) center center no-repeat;

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

    color: #000;

    }

    p{

    font: normal 12px Arial, Helvetica, sans-serif;

    color: #000;

    }

    #header{

    width: 780px;

    padding: 10px;

    margin-left: auto;

    margin-right: auto;

    background: #ffc;

    }

    #navbar{

    width: 780px;

    padding: 10px;

    margin-left: auto;

    margin-right: auto;

    background: #fff;

    }

    #navbar ul{

    list-style: none;

    }

    #navbar li{

    display: inline;

    padding-right: 4%;

    }

    #navbar a:link,#navbar a:visited{

    font: normal 12px Arial, Helvetica, sans-serif;

    color: #039;

    text-decoration: none;

    }

    #navbar a:hover{

    text-decoration: underline;

    }

    #mainwrapper{

    clear: both;

    width: 800px;

    height: 100%;

    margin-left: auto;

    margin-right: auto;

    overflow: hidden;

    background: #fff;

    }

    #mainwrapper .leftcol{

    position: relative;

    float: left;

    }

    #mainwrapper .rightcol{

    position: relative;

    float: right;

    }

    #leftbar{

    width: 180px;

    padding: 10px;

    }

    #centerbar{

    float: left;

    width: 380px;

    padding: 10px;

    background: #fff;

    }

    #rightbar{

    width: 180px;

    padding: 10px;

    }

    #footer{

    clear: both;

    width: 780px;

    padding: 10px;

    margin-left: auto;

    margin-right: auto;

    background: #ffc;

    }

    .contbox{

    padding: 10px;

    background: #6cf;

    }

    </style>

    </head>

    <body>

    <div id="header">

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

    <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">

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

    <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">

    <h2>Left column of the web page</h2>

    <div class="contbox">

    <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 id="centerbar" class="leftcol">

    <h1>Center column of the web page</h1>

    <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 id="rightbar" class="rightcol">

    <h2>Right column of the web page</h2>

    <div class="contbox">

    <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="footer">

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

    <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>


    As you can see, the CSS styles of the above (X)HTML file includes the following declaration:


    h2{

    padding: 7px 5px 8px 5px;

    margin: 0;

    background: #6cf url(rounded_corners_transp.gif) center center no-repeat;

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

    color: #000;

    }


    Naturally, this CSS style is the one that actually assigns the “rounded_corners_transp.gif” image to all of the previous <h2> web page headers. The image in question, for the sake of clarity, originally looked like this:



    And finally, here’s the final appearance of one of the main containers included into the pertinent web page, after styling it with the aforementioned transparent background image:



    Well, at this point you certainly recalled how to build some basic rounded corners by utilizing a unique transparent GIF. So considering this, it’s time to move on and see how to implement this same approach in order to create a few simple angled corners logically using the sample web page that was shown before.

    To see how this web page effect will be achieved, please click on the link below and keep reading.

    More Style Sheets Articles
    More By Alejandro Gervasio


       · In the course of this second part of the series, you’ll see you how to use...
     

    STYLE SHEETS ARTICLES

    - Creating Gradients for Individual Containers...
    - Creating Gradients for Web Page Headers with...
    - SEO Scrolling Frames Problem Solved
    - Building Cross-Browser Background Effects wi...
    - CSS: Pseudo
    - Using PNG Images to Build Background Effects
    - CSS: Continuing the Clarification of CSS Cla...
    - CSS: Top Secret Classification
    - CSS: Dimensions
    - CSS: Margins and Padding
    - CSS: Crossing the Border
    - CSS: Text, Fonts, and Tables
    - CSS: Working with Text
    - CSS: Backgrounds
    - CSS for the Newbie







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway