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:
- 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/. - Or instead of inlining your elements you just go with
display:block
andfloat: left
.
Try setting padding and margin to 0:
#ul_id li{
padding:0px;
margin:0px;
}
精彩评论