开发者

Spaces between inline list items when code is on separate lines

If I code inline list items on separate lines of code there is a space inserted between them.

Is there a way to prevent this from happening with coding all of the list items on the same line of code?

<li>12开发者_C百科3</li>
<li>456</li>

creates the following which I don't want

123 456

<li>123</li><li>456</li>

creates the following which i do want

123456

thanks


I'm assuming you use CSS display: inline to inline your list items?

display: inline does exactly that: it converts your new line in your source code to a space character. You have two options now:

  1. Either you write all your <li> items in one line, then display: inline will actually make your list items behave like you want (no space in-between) - I have set up an example for you here: http://www.jsfiddle.net/NxrQ9/.
  2. Or instead of inlining your elements you just go with display:block and float: left.


Try setting padding and margin to 0:

#ul_id li{
  padding:0px;
  margin:0px;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜