Style Sheets
  Home arrow Style Sheets arrow Page 4 - Adjusting Padding and Margins on Floating ...
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

Adjusting Padding and Margins on Floating Lists with CSS
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-12-17

    Table of Contents:
  • Adjusting Padding and Margins on Floating Lists with CSS
  • A review of our cross-browser approach
  • Assigning padding, margins and widths
  • Controlling the indentation of bullets

  • 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


    Adjusting Padding and Margins on Floating Lists with CSS - Controlling the indentation of bullets


    (Page 4 of 4 )

    As I stated in the prior section, the last adjustment that I’m going to introduce to the floating lists is with reference to the indentation of their bullets. This minor modification can be easily performed by assigning fixed values for the left padding of the lists, so now that you know how this final change will be implemented, please take a look at the following (X)HTML file, which this time displays the floating lists with the new padding values:


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

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

    <title>Basic example on building floating lists</title>

    <style type="text/css">

    body{

    padding: 0;

    margin: 0;

    background: #fff;

    }

    h1{

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

    color: #000;

    }

    #listcontainer{

    width: 1000px;

    }

    ul.leftlist{

    float: left;

    width: 350px;

    position: relative;

    padding: 0 20px;

    margin: 0;

    list-style-position: inside;

    list-style-type: square;

    }

    ul.rightlist{

    float: right;

    width: 350px;

    position: relative;

    padding: 0 20px;

    margin: 0;

    list-style-position: inside;

    list-style-type: square;

    }

    </style>

    </head>

    <body>

    <h1>Basic example on building floating lists</h1>

    <div id="listcontainer">

    <ul class="leftlist">

    <li>This is the list item 1, floated to the left.</li>

    <li>This is the list item 2, floated to the left.</li>

    <li>This is the list item 3, floated to the left.</li>

    <li>This is the list item 4, floated to the left.</li>

    <li>This is the list item 5, floated to the left.</li>

    </ul>

    <ul class="rightlist">

    <li>This is the list item 1, floated to the right.</li>

    <li>This is the list item 2, floated to the right.</li>

    <li>This is the list item 3, floated to the right.</li>

    <li>This is the list item 4, floated to the right.</li>

    <li>This is the list item 5, floated to the right.</li>

    </ul>

    </div>

    </body>

    </html>


    Here you have it. As you can see on the above hands-on example, I assigned to the respective lists a left padding value of 20px, in addition to specifying a relative position for each of them. Also, you’ll have a better idea of the visual appearance of these floating lists if you look at the following screen capture:



    Definitely, you’ll have to agree with me that building floating HTML lists with CSS is a straightforward process that can be learned in a short time. Of course, you’re completely free to use all of the code samples included in this tutorial to start incorporating floating lists into your own web sites.

    Final thoughts

    In this third chapter of the series, I showed you how to improve the look and feel of the corresponding HTML lists by controlling their padding, margins and widths. I also modified the indentation of list bullets, but naturally all of these changes to the lists’ styles are completely optional, and it’s up to you decide when and how to apply them.

    In the final installment, I’m going to teach you how to use these recently-styled floating lists in the context of a real-world example, where you’ll be able see how to utilize them along with paragraphs and other common web page elements.

    Now that you know what the next article will be about, you can’t miss it!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This third article of the series demonstrates how simple is to adjust certain...
       · How do you handle the expanding box problem with these floats?
       · In most cases, overflow: hidden; will fix up the bug, but it depends on the content...
     

    STYLE SHEETS ARTICLES

    - 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...
    - Pulling Web Page Elements with the Blueprint...
    - Pushing Web Page Columns with the Blueprint ...
    - Controlling Column Padding with the Blueprin...
    - Prepending Classes in the Blueprint CSS Fram...
    - Appending Grid Units with the Blueprint CSS ...
    - Changing Grid Units in the Blueprint CSS Fra...
    - The Blueprint CSS Framework
    - Building a Liquid Design with Evened Margins...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT