Display: inline-block and center aligning
#words { width: 600px; height: 450px; overflow-x: hidden; overflow-y: auto; border: 1px solid black; }
#words li { display: inline-block; width: auto; padding: 10px; height: auto; background-color: #c4c4c4; margin: 2px; text-align: center; }
So that's my CSS code for my mark-up:
<ul id="words">
<li>blah</li>
<li>blah</li>
<li>blah</li>
<li>blah</li>
<li>blah</li>
<li>blah</li>
<li>blah</li>
<li>blah</li>
<li>blah</li>
</ul>开发者_如何学运维;
But, I cannot seem to have width:auto;
on the <li>
without floating them left (in FireFox).
Any ideas?
If you want it stacked up vertically (as I understand) then you just need to remove "inline-" from your words li
selector:
#words li
{
display: block;
...
}
Example here.
Nevermind, I sorted it.
#words
now has text-align: center;
精彩评论