开发者

Styling unordered horizontal list with ...best possible way

开发者 https://www.devze.com 2022-12-20 02:01 出处:网络
To make lists horizontal and hide default bullets, is it necessary to give {display:inline} and {float:left} both to the <li> tags or anyone of these alone is enough?

To make lists horizontal and hide default bullets, is it necessary to give {display:inline} and {float:left} both to the <li> tags or anyone of these alone is enough?

<ul>
<li><a href="#">First item</a></li>
<l开发者_如何学Pythoni><a href="#">item 2</a></li>
<li><a href="#">item 3</a></li>
<li><a href="#">item 4</a></li>
<li><a href="#">Last item</a></li>
</ul>

How to make cross browser (including IE6 and FF2) , pixel perfect horizontal list without bullet in best way?

What is best and short method?

ul {}
li {}
a  {}


No, either one alone is enough. You could even use inline-block if you like, although it doesn't have very good support in FF2. Hiding bullets is done with list-style:none;

You could setup a simple test quickly to check these:

#one, #two, #three { list-style:none }
#one li            { float:left }
#two li            { display:inline }
#three li          { display:inline-block }
<ul id="one">
  <li>Float left</li> 
  <li>In this example</li>
</ul>
<div style="clear:both"></div>
<ul id="two">
  <li>Display inline</li>
  <li>In this example</li>
</ul>
<div style="clear:both"></div>
<ul id="three">
  <li>Inline-block</li>
  <li>In this example</li>
</ul>

See how they render: http://jsbin.com/opiqu3/


display:inline is not necessary but float:left is necessary to make it horizontal and like you said about hiding default bullets, then even list-style:none is also necessary.

0

精彩评论

暂无评论...
验证码 换一张
取 消