Style Sheets
  Home arrow Style Sheets arrow Page 7 - Double Vision – Give the Browsers CSS They...
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  
Moblin 
JMSL Numerical Library 
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

Double Vision – Give the Browsers CSS They Can Digest
By: Chris Heilmann
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 11
    2005-02-22

    Table of Contents:
  • Double Vision – Give the Browsers CSS They Can Digest
  • The way of the dark side – code forking
  • The way of confusion – browser hacks
  • The way into the future – progressive enhancement
  • The child selector
  • Enhancing with the child selector
  • The screen display style sheet
  • The print style sheet

  • 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


    Double Vision – Give the Browsers CSS They Can Digest - The screen display style sheet


    (Page 7 of 8 )


     

    The document has a table of contents linking to different headlines in the document via their ID. For non–CSS browsers this one gets displayed before the content. For the others, we want to display the table of contents next to the main text. We achieve that by positioning the TOC absolutely and giving the content a margin. Giving the content a vertically repeater background separates it from the TOC even further. We can apply a background to the content, as we know that it will always be longer than the TOC, otherwise, we’d have to use a background on the parent element of the two.

     

    #toc{

        position:absolute;

        top:0;

        z-index:10;

        right:1em;

        width:17em;

    }

    #content{

        margin:0 16em 0 0;

        padding:0 2em 0 0;

        background:url(tocback.gif) repeat-y right 0 #f8f8f8;

    }

     

    The rest of the styling is more or less eye-candy. We define how links look in the content and the TOC, the same for lists and headlines. As technical articles often feature code examples that may break the layout, we set the overflow attribute of those to scroll, forcing the browser to display a scrollbar instead of expanding the whole page horizontally.

     

    #content pre{

        margin:1em 3em;

        width:35em;

        overflow:scroll;

        padding:.5em;

        border:1px solid #999;

        background:#eee;

    }

     

    That is as far as we go for CSS2 challenged browsers like MSIE. For the Gecko, Opera or KHTML browsers out there, we go further by fixing the TOC to stay next to the content at any time.

     

    html>body #toc{

               position:fixed;

    }

     

    This, however, renders the “back to table of contents” links useless, as the TOC never leaves the screen. Therefore we hide them:

     

    html>body #content p.backlink{

               position:absolute;

               left:-999em

    }

     

    More Style Sheets Articles
    More By Chris Heilmann


       · Some browsers understand both imports but don't display CSS2 properly - so this will...
       · which ones? The only one that comes to mind is Opera < 7.
     

    STYLE SHEETS ARTICLES

    - Swapping Column Positions in Web Page Layout...
    - Creating Web Page Layouts with Negative Marg...
    - 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







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