Jump to content

float right reverses list items?


ifubad

Recommended Posts

    #con ul li {
        display: inline;
        float: right;
    }

    <div id="con">
    <ul>
          <li><a href="#">Link 1</a></li>
          <li><a href="#">Link 2</a></li>
    </ul>
    </div>

 

I just noticed using float:right on a <ul> will display the <li> order in reverse (i.e. instead of displaying it as "Link 1 Link 2", it's "Link 2 Link 1"). Is the only way to work around this is to reverse the <li> order in the markup?

Link to comment
Share on other sites

Okay well you don't need float and the inline display. Try this out:

 

<style type="text/css">
    #con ul {
        float: right;
    }

#con li {
	float:left;
	list-style-type:none;
}
</style>

    <div id="con">
    <ul>
          <li><a href="#">Link 1</a></li>
          <li><a href="#">Link 2</a></li>
    </ul>
    </div>

Link to comment
Share on other sites

    #con ul li {
        display: inline;
        float: right;
    }

    <div id="con">
    <ul>
          <li><a href="#">Link 1</a></li>
          <li><a href="#">Link 2</a></li>
    </ul>
    </div>

 

I just noticed using float:right on a <ul> will display the <li> order in reverse (i.e. instead of displaying it as "Link 1 Link 2", it's "Link 2 Link 1"). Is the only way to work around this is to reverse the <li> order in the markup?

 

Obviously this will be in reverse order, because you float the <li> right! - Why would you do that? You can float them left and float only the <ul> to the right. Unfortunately, that is still a poor way to lay the code out. If you explain what you are trying to achieve, I will be more than happy to help!

Link to comment
Share on other sites

after both replies, I now understand more on why it's doing what it's doing.

 

Obviously this will be in reverse order, because you float the <li> right! - Why would you do that?

 

Just practicing, trying to emulate the youtube home page. I now also see when display:inline is not necessary.

 

Thnx to both

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.