Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-06-2011, 11:12 AM   PM User | #1
IamHe
New Coder

 
Join Date: Mar 2009
Posts: 88
Thanks: 14
Thanked 0 Times in 0 Posts
IamHe is an unknown quantity at this point
Aligning Menu Items

I orgionally got help with this from Bullant about a month ago but im now trying to make an alteration but am not having much look.

i have a div menu code and at current the menu items are centerd within the div container.

i want them to start from the left rather than the centre.

would really appreciate any help.

thanks

Code:
<!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=utf-8" />
        <title></title>
        <style type="text/css">
            #menuContainer {
                width: 900px;
                overflow: hidden;
                border: 1px solid red;
                margin: 0px auto 0px auto;
            }
            #menu {
                list-style-type: none;
                margin: 0px 0px 0px 0px;
                padding: 0px 0px 0px 0px;
                float: left;
                position: relative;
                left: 50%;
            }
            #menu li {
                float: left;
                position: relative;
                right: 50%;
            }
            #menu li a {
                margin: 0px 10px 0px 10px;
                padding: 5px 5px 5px 5px;
            }
        </style>
        <script type="text/javascript"></script>
    </head>
    <body>
        <div id="menuContainer">
            <ul id="menu">
                <li><a href="link1.htm">item1</a></li>
                <li>|</li>
                <li><a href="link2.htm">item2</a></li>
                <li>|</li>
                <li><a href="link3.htm">item3</a></li>
                <li>|</li>
                <li><a href="link4.htm">item4</a></li>
            </ul>
        </div>
    </body>
</html>
IamHe is offline   Reply With Quote
Old 05-06-2011, 02:13 PM   PM User | #2
teedoff
Senior Coder

 
Join Date: Aug 2010
Location: High Point, NC
Posts: 3,325
Thanks: 5
Thanked 363 Times in 360 Posts
teedoff is on a distinguished road
Code:
#menuContainer {
                width: 900px;
                overflow: hidden;
                border: 1px solid red;
                margin: 0px auto 0px auto;
Might have something to do with the code in orange. Remember, anything with a specified width less than its containing element, AND margin left and right set to auto, will center itself.
__________________
Teed
teedoff is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:50 PM.


Advertisement
Log in to turn off these ads.