Style Sheets
  Home arrow Style Sheets arrow Page 2 - CSS: Top Secret Classification
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

CSS: Top Secret Classification
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2008-04-14

    Table of Contents:
  • CSS: Top Secret Classification
  • Floating Elements
  • Floating Text for a Fairy Tale Look
  • Creating a Menu

  • 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


    CSS: Top Secret Classification - Floating Elements


    (Page 2 of 4 )

    You can make elements float to left or right of text using float. This determines where an image or some text will appear in another element. Here, in the example below, we will float an image to the left and then the right of some paragraphs:


    <html>

    <head>

    <style type="text/css">

    img

    {

    float:left

    }

    img.right

    {

    float:right

    }

    </style>

    </head>

    <body>

    <p>

    <img src="sample.gif" width="100" height="100" />

    Bruce Lee sat staring at the universe, the Milky Way portion particularly. The planet he named Earth when he created it was at the furthest end and he did not like it there, so he round-kicked it into a position closer to the sun. And thus, life on Earth was possible.

    </p>

    <p>

    <img class="right" src="sample.gif" width="100" height="100" />

    On another occasion Bruce Lee got into an argument with the Greek God Zeus. Things quickly escalated, as Bruce will not be disrespected, and he pimp slapped the thunderbolt out of Zeus. The Greek god was so upset he cried for 40 days and 40 nights, forcing God to tell Noah to build the ark. On the forty-first day, Zeus apologized.

    </p>

    </body>

    </html>

    Note that you can always set the float value to none, but then, why bother doing it at all?

    Here is a similar example, where we give an image some border properties and use margins on one of the images so the text does not hug it:


    <html>

    <head>

    <style type="text/css">

    img

    {

    float:left;

    border:1px dashed red;

    margin: 0px 10px 10px 15px

    }

    img.right

    {

    float:right;

    border: 1px dotted blue

    }

    </style>

    </head>

    <body>

    <p>

    <img src="sample.gif" width="100" height="100" />

    Bruce Lee sat staring at the universe, the Milky Way portion particularly. The planet he named Earth when he created it was at the furthest end and he did not like it there, so he round-kicked it into a position closer to the sun. And thus, life on Earth was possible.

    </p>

    <p>

    <img class="right" src="sample.gif" width="100" height="100" />

    On another occasion Bruce Lee got into an argument with the Greek God Zeus. Things quickly escalated, as Bruce will not be disrespected, and he pimp slapped the thunderbolt out of Zeus. The Greek god was so upset he cried for 40 days and 40 nights, forcing God to tell Noah to build the ark. On the forty-first day, Zeus apologized.

    </p>

    </body>

    </html>

    And in this example, we will add a caption to one of our floating images:


    <html>

    <head>

    <style type="text/css">

    div

    {

    float:left;

    border:1px dashed red;

    margin: 10px 10px 10px 15px;

    text-align:center;

    padding:20px

    }

    img.right

    {

    float:right;

    border: 1px dotted blue

    }

    </style>

    </head>

    <body>

    <div>

    <img src="sample.gif" width="100" height="100" /><br />Bruce Lees pwns Joo!

    </div>

    <p>Bruce Lee sat staring at the universe, the Milky Way portion particularly. The planet he named Earth when he created it was at the furthest end and he did not like it there, so he round-kicked it into a position closer to the sun. And thus, life on Earth was possible.

    </p>

    <p>

    <img class="right" src="sample.gif" width="100" height="100" />

    On another occasion Bruce Lee got into an argument with the Greek God Zeus. Things quickly escalated, as Bruce will not be disrespected, and he pimp slapped the thunderbolt out of Zeus. The Greek god was so upset he cried for 40 days and 40 nights, forcing God to tell Noah to build the ark. On the forty-first day, Zeus apologized.

    </p>

    </body>

    </html>

    More Style Sheets Articles
    More By James Payne


       · This article was great. It gave me the information I needed to know and an clear...
       · Thanks for stopping by to read my article. In this issue I discuss such topics as...
     

    STYLE SHEETS ARTICLES

    - Image Replacement CSS Techniques
    - Using BlueTrip`s Success, Notice and Error C...
    - More Uses for the Thin and Caps CSS Classes ...
    - Styling Definition Lists with the BlueTrip C...
    - Styling Unordered and Ordered HTML Lists wit...
    - Using the BlueTrip CSS Framework`s Thin and ...
    - Adding Borders to Web Page Columns with Blue...
    - Introducing the BlueTrip CSS Framework
    - Using a Background Grid to Assist Web Page L...
    - Extending the Rule Of Thirds for Web Page La...
    - A Two-Column Web Page Layout Based on the Ru...
    - Using the Rule Of Thirds for Web Page Layout
    - Swapping Columns Using the Divine Ratio for ...
    - Using the Golden Ratio in Liquid Web Page De...
    - Fundamental Design Principles for Web Page L...







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