2

I know this has been discussed here before - as I've read through a lot of questions about the same thing. And have tried the solutions, but I just can't seem to make this stupid nav right align (needing li blocks to align to the right). Can someone please point out my mistake - thank you.

http://jsfiddle.net/gstricklind/vP38J/4/

CSS

ul#menu-main-top {
    float: right;
}
.nav-bar > li {
    border: 1px solid #333;
    display: block;
    float: left;
    line-height: 38px;
    margin: 0;
    padding: 0;
    position: relative;
}
ul#menu-main-top li a {
    color: #222222 !important;
}
.top-nav > li > a {
    color: #E6E6E6 !important;
}
.nav-bar > li > a:first-child {
    margin: 0 0 0 10px;
    padding: 0 0 0 30px;
}
.nav-bar > li > a:first-child {
    display: block;
    font-size: 14px;
    padding: 0 20px;
    position: relative;
    text-decoration: initial;
}

HTML

<div class="eight columns">
    <ul id="menu-main-top" class="top-nav nav-bar hide-for-small">
        <li id="menu-item-58">                
            <a href="#">Home</a>
        </li>
        <li id="menu-item-94">
            <a href="#">Calendar</a>
        </li>
        <li id="menu-item-59">
            <a href="#">Meanings</a>
        </li>
        <li id="menu-item-77">
            <a href="#">About Us</a>
        </li>
        <li id="menu-item-67">
            <a href="#">Contact Us</a>
        </li>
        <li id="menu-item-343" class="active">
            <a href="#">My Account</a>
        </li>
        <li class="logout">
            <a href="#">Logout</a>
        </li>
    </ul>                    
</div>
gstricklind
  • 464
  • 2
  • 6
  • 17
  • Looks aligned to the right to me. What's wrong with it? – jamesplease Jan 02 '13 at 23:48
  • All the li's align to the left inside the ul. The ul aligns right. But I need all li's to align right. So that when more li's are added, they don't start at the left, but the right. Am I making sense? I've tested (or tried) in Safari, Firefox, and Chrome. – gstricklind Jan 02 '13 at 23:56
  • Sorry, changed the title - it may have been confusing. – gstricklind Jan 03 '13 at 00:01

1 Answers1

5

Is this what you were trying to do?

http://jsfiddle.net/vP38J/5/

Relevent changed code:

.nav-bar > li {
    border:1px solid #333;
    display:block;
    float: right;
    line-height:38px;
    margin:0;
    padding:0;
    position:relative;
 }

Also, if you are looking to have the order remain the same, just reverse the order of the list in HTML.

  • Yes, but then the links are reversed. I'm trying to align it like that, but the link order needs to be normal. Normally I don't have a problem figuring this out.. not sure what I've done wrong this time. – gstricklind Jan 03 '13 at 00:09
  • 4
    Perhaps this solution works better for what you want: http://jsfiddle.net/vP38J/7/ I changed the li from block to inline-block and removed the float. Then added a text-align right to the ul. – Chris Christensen Jan 03 '13 at 00:11
  • I think that's it! I'm not sure why I didn't think about removing that float: left from the li. Thank you! – gstricklind Jan 03 '13 at 00:31
  • Can you edit your answer to reflect the changes so I can accept it? – gstricklind Jan 03 '13 at 00:33
  • 1
    Remember that ie7 has issues with `display: inline-block;` so you will need to apply some fixes if you want to support it: http://stackoverflow.com/questions/6544852/ie7-does-not-understand-display-inline-block – 3dgoo Jan 03 '13 at 02:26