Forum Moderators: not2easy

Message Too Old, No Replies

Problem with a styled, unordered list

duplicate list items and random line breaks

         

Hi_There

6:42 pm on Jul 9, 2009 (gmt 0)

10+ Year Member



Hello,

I want to first mention that I've studied the site in question from dozens of different computers and browsers and there is only ONE computer/browser combination that renders it this way. My colleague saw it when she was browsing the site on her computer at work. I believe she's running IE7. (However, I run IE7 on my computer at home also and it works fine for me).

Here is a description of the problem:

There are 13 list items. On the computer mentioned above, the last three lines appear exactly as follows:

Premium Mannequins

emium Mannequins
All Mannequins

However, it should look like this:

Premium Mannequins
All Mannequins

Basically, it is duplicating the second to last line and adding what looks like two line breaks.

I have 3 other separate instances of this same unordered list on the page with different items and each one is rendering a similar error in the same place at the end of each list.

Here's my HTML code:

<body>
<ul class="left">
<li><a href="#" title="#"><strong class="HideStrong">list item</strong></a></li>
<li><a href="#" title="#"><strong class="HideStrong">list item</strong></a></li>
<li><a href="#" title="#"><strong class="HideStrong">list item</strong></a></li>
<li><a href="#" title="#"><strong class="HideStrong">list item</strong></a></li>
<li><a href="#" title="#"><strong class="HideStrong">another list item this text repeats</strong></a></li>
</ul>
</body>

...and here's my CSS:


ul.left {
list-style: none;
margin: 0 auto;
padding: 0;
width: 100%;
}
ul.left li {
display: inline;
}
ul.left li a {
font-family: verdana, arial, "trebuchet ms", sans-serif;
padding: 1px 0px 1px 0px;
margin: 0px 0px 0px 0px;
width: 100%;
text-decoration: none;
letter-spacing: 0px;
word-spacing: 0px;
color: #000000;
font-size: 10pt;
float: left;
text-align: left;
font-variant: normal;
}
ul.left li a:hover {
color: #877C00;
background-image:url('left menu hover star.gif');
background-repeat: no-repeat;
background-position: center right;
}
img.catHeading {
padding-bottom: 5px;
}

Does anyone know what's going on here? Any help would be greatly appreciated.

Thank you

[edited by: SuzyUK at 9:34 am (utc) on July 10, 2009]
[edit reason] examplified, shortened HTML [/edit]

jameshopkins

9:11 am on Jul 10, 2009 (gmt 0)

10+ Year Member



I suggest that your colleague is using IE6, for the reasons below.

This is a known duplicate character bug in IE6, which can be fixed by applying a negative 3px right margin to the last sibling in the series that is floated left. So, adding 'margin-right:-3px;' to the last sibling of ul.left li a, should fix the issue. In reality, you'll need to define either an ID or class to this particular element, and then apply the negative margin to that ID or class; this is since IE doesn't understand the CSS3 :last-child pseudo class.

SuzyUK

9:40 am on Jul 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It it the duplicating character bug, which is hasLayout related. rather than go the negative margining route and having to find that last child <li> - you could also fix it by adding 'layout' to the <li>'s avoiding any other potential IE6 bug creeping in too.

The simplest way to do that in this case might be to float the <li>'s in these lists, to contain the child floats, the links themselves.

ul.left li {
display: inline;
float: left;
}

Hi_There

6:48 pm on Jul 10, 2009 (gmt 0)

10+ Year Member



Thank you two very much for your help! The problem is fixed. You definitely got me on the right track with your posts. Apparently all I needed to do was add {display:inline} to the entire ul.left like this:


ul.left {
list-style: none;
margin: 0 auto;
padding: 0;
width: 100%;
display: inline;
}

Initially, I tried adding float: left...


ul.left li {
display: inline;
float: left;
}

However, this messed up the list even more for some reason. But everything is all better now. And yes, as it turns out, she was using IE6.

Thanks again for your help :)