Forum Moderators: not2easy

Message Too Old, No Replies

Issue with formatting a list

         

chuckee

3:14 am on Jun 29, 2007 (gmt 0)

10+ Year Member



Hi,
I was trying to put whitespace *between items* in a list of mine, but if any of the items in the list wraps around onto a new line, the same spacing is used between lines of text in the same item.

I only want white space between the items on the list - I don't want whitespace between lines of text that are part of the same item.
Check it out (this is an html file which will show the problem):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<style type="text/css">
#list_benefits li {
line-height: 2.2em;
}
</style>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>

<ul id="list_benefits" >
<li>Content sdsf sdfsdfsddfsdf sdfs fdfsf sdf</li>
<li>Content sdsf sdfsdfsddfsdf sdfs fdfsf sdf</li>
<li>Content sdsf sdfsdfsddfsdf sdfs fdfsf sdf</li>
<li>Content sdsf sdfsdfsddfsdf sdfs fdfsf sdf</li>
<li>Content sdsf sdfsdfsddfsdf sdfs fdfsf sdfdfgdfggfgdgfdfgfg dfg d df dfgd fggd fgdgfd ffd gdfgdff ggf df gdfgdfgdgfddggfdg dfgdfg dgf dfgddf gdgf dfgdgdfgd fgd fgd g d fg d fd fg dg df dfg dg d fgd fgd fgd fgd fg dfg dg fd d gd fg dg dfg fdg dg df dg df</li>
<li>Content sdsf sdfsdfsddfsdf sdfs fdfsf sdf</li>
</ul>
</body>
</html>

Robin_reala

10:14 am on Jun 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Instead of using line-height you probably just want to apply a margin or padding to each list item.

chuckee

4:02 am on Jul 5, 2007 (gmt 0)

10+ Year Member



Thanks Robin.
I used margin-bottom and that worked well.

I have just one more issue. When I use an image as the bulletpoint, the image always centres itself vertically on a bulletpoint, if the text for that bulletpoint has more than one line. I would prefer it if the bulletpoint image was always next to the *1st* line of text in a bulletpoint. Is there a way to do this?
Here is my code (note: you will need an image in this location /images/tick.gif):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<style type="text/css">
#list_benefits li {
list-style-type: none;
background-image: url(/images/tick.gif);
background-repeat: no-repeat;
padding-left: 3.4em;
margin-bottom: 15px;
background-position: 2em;
}
</style>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>

<ul id="list_benefits" >
<li>Content sdsf sdfsdfsddfsdf sdfs fdfsf sdf</li>
<li>Content sdsf sdfsdfsddfsdf sdfs fdfsf sdf</li>
<li>Content sdsf sdfsdfsddfsdf sdfs fdfsf sdf</li>
<li>Content sdsf sdfsdfsddfsdf sdfs fdfsf sdf</li>
<li>Content sdsf sdfsdfsddfsdf sdfs fdfsf sdfdfgdfggfgdgfdfgfg dfg d df dfgd fggd fgdgfd ffd gdfgdff ggf df gdfgdfgdgfddggfdg dfgdfg dgf dfgddf gdgf dfgdgdfgd fgd fgd g d fg d fd fg dg df dfg dg d fgd fgd fgd fgd fg dfg dg fd d gd fg dg dfg fdg dg df dg df</li>
<li>Content sdsf sdfsdfsddfsdf sdfs fdfsf sdf</li>
</ul>
</body>
</html>

Marshall

4:47 am on Jul 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Instead of background image, use

list-style-image: url(images/tick.gif);

Marshall

lavazza

6:50 am on Jul 5, 2007 (gmt 0)

10+ Year Member



I once had a v similar set up and then had problems when, rather than:
<ul id="list_benefits"> for use <2
<ul class="list_benefits"> for use >1

The following validates (HTML 4.01 Transitional, loose) and looks v similar in FF2, IE7 and Opera9
--------

<style type="text/css">
UL.myUL{
list-style-image: url(images/favicon.ico);
padding-left:5em;
padding-bottom:0em;
}

LI.myLI{
padding-bottom:1em;
}
</style>

<ul class="myUL">
<li class="myLI">Nunc velit. Integer auctor, ante sit amet laoreet pulvinar, purus erat scelerisque enim,
ut convallis diam sapien eu nibh. Vestibulum mi ligula, euismod non, blandit nec, luctus eget, enim.
Vestibulum eu leo nec leo sagittis aliquet. Pellentesque habitant morbi tristique senectus et netus et
</li> <li class="myLI">Vestibulum mi ligula, euismod non, blandit nec, luctus eget, enim.
</li> <li class="myLI">Pellentesque habitant
</li>
</ul>

<p>
Curabitur tortor ligula, condimentum id, adipiscing at, faucibus vel, est. Quisque scelerisque nibh
vel libero. Nam suscipit ante in arcu. Proin non libero sit amet turpis cursus venenatis.
</p>

<ul class="myUL">
<li class="myLI">Nunc velit
</li> <li class="myLI">Nunc
</li>
</ul>