Reputation: 14290
I have a question regarding the ul list
I have something like
<div>
<ul id='login'>
<li>button1</li>
<li>button2</li>
<li>button13</li>
</ul>
</div>
I want them float to the right side of the page
-------------------------------------------------------------------
| button1 button2 button3 |
|
|
my css
#login li{
display: inline;
text-align: right;
}
It turns out like
-------------------------------------------------------------------
| button3 button2 button1
|
|
I can simply do the following but I don't want to change the order in html.
<div>
<ul id='login'>
<li>button3</li>
<li>button2</li>
<li>button11</li>
</ul>
</div>
Is there anyway to fix this problem? Thanks!
Upvotes: 0
Views: 44
Reputation: 253486
I'd suggest not floating anything, and just using text-align
to place the inline-block
elements against the right-side of the screen:
#login {
text-align: right;
}
#login li {
display: inline-block;
}
Upvotes: 2
Reputation: 12730
This should do it:
#login {
display: inline-block; /* ul width adapts to its content */
float: right; /* clears unused left space */
overflow: hidden; /* Or some other clearfix method */
}
#login li {
display: inline-block; /* permits further link enhancements: height, margin, etc. */
}
Upvotes: 2