Forum Moderators: not2easy

Message Too Old, No Replies

multicolumn lists in IE 7 - why won't they align?

         

greygoose

3:12 pm on Nov 14, 2008 (gmt 0)

10+ Year Member



I incorporated this code from a tutorial into my own page and it displays well in Firefox [mac], but is only slightly off in explorer. For now, I've set the top margin in px .. I did play around with percentages and that seemed to exacerbate the problem. Is there any fix? Could the other elements on the page be the culprit?

the original code was based on 3 columns of equal height (maybe that's the trouble?) but I adapted it slightly for 2 columns.
HTML: <span> repeated for all items
<ul>
<li class="licol-1"><span>Item one</span></li>
<li class="licol-1">Item two</li>
<li class="licol-1">Item three</li>
<li class="licol-1">Item four</li>
<li class="licol-2 licol-first">Item five</li>
<li class="licol-2">Item six</li>
<li class="licol-2">Item seven</li>
<li class="licol-2">Item eight</li>
</ul>

}
#colTwoPerf li {
width:42%; /*even shrinking this doesn't seem to make a difference*/
margin:15px 0 0 0;
padding:0 15px 0 0;
line-height:15px;
position:relative; /* IE needs this in order to recognise links in all columns */
color: orange;
}

#colTwoPerf li span {
color:#666666;}

#colTwoPerf li.licol-1 {
margin-left:0px;
}
#colTwoPerf li.licol-2 {
margin-left:360px
}

#colTwoPerf li.licol-first {
margin-top:-285px;
}
#colTwoPerf li.licol-1a {
margin-left:0px;
}
#colTwoPerf li.licol-2a {
margin-left:360px
}

#colTwoPerf li.licol-first-a {
margin-top:-255px;
}


swa66

4:15 pm on Nov 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What happens if due to user style sheets or differences in fonts the content of one of your <li>s wraps ?

greygoose

7:05 pm on Nov 14, 2008 (gmt 0)

10+ Year Member



Well I guess it's all a big mess... I tried to shorten the lines now. The content isn't up to me, unfortunately.
Wrapping, I see, is a problem in IE because the bullet aligns with the bottom line of text, rather than the top.

The request was for a 2-column list under the two headings that appear on the page. It's a good way of presenting the info, but if it never displays properly, are there any other options?

alt131

3:57 am on Nov 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi greygoose,

I'm on a pc, not a mac, and both winSafari and FF (supposedly the same cross-platform) refused to display your licol-2 list items in the provided code. Plus your reference to ie suggest ie5 for mac, which is quite different from the pc versions. That makes it makes it difficult to understand what you mean by descriptions such as "slightly off", etc.

There are many ways to do this, and after looking at a range of options based on your code, I think what is best will depend on:
# How long each of the lists are - how much effort and code you put into this
# How many of the list items will wrap, how many lines there will be -and whether you can change the order of the list items to work around that
# Whether you are prepared to accept stuctural mark-up
# what exactly is in the list - images, links, etc.

Some immediate thoughts on the code:
# The span appears to enable a colour change between bullet and text. If the real world text is links, colour the links, and avoid the span
# bullet alignment after wrapping in ie (pc} can be fixed by using

vertical-align
- although it throws out other browsers that do not apply it.
# try setting a height on the li's to avoid the troubles caused by using
line-height
for more than one line.
# If the list content includes images, can the images be set to "hold open" the <li>'s to create adequate height even if the text wraps

Work-arounds might be:
#Float the li and use &bull; to simulate a bullet
#Float two <ul> side-by-side so there is no need to float the li.
#Use a definition list using the <dt> for headings and the <dd>'s for your list.
# Accept having to class more than one li and add in the additional heights for the ones that need to wrap and their "opposite" so the list will visually display with each list item appearing to start on the same "line"

The code suggests you are trying to "position" each of the <li>'s using margins. I'd suggest best to use conventional positioning techniques - perhaps post some real-world code?

greygoose

5:18 am on Nov 16, 2008 (gmt 0)

10+ Year Member



I was referring to IE for PC since it's the most common browser apparently and I'm trying to "optimize" for the most prevalent browser + resolution.

This is a list of text - some items are single words and a couple are a few more, causing wrapping. The span colours the bullet and text differently. Large headings appear outside the list.
Thank you for those suggestions.. the tutorial I read also mentioned floating and its inherent problems! The margin technique finally worked in IE, but each line contained only one word, which may not suit the client.. also didn't quite display properly in FF in the end.

My next plan is to do a TABLE. Does this sound feasible?
My first attempt had the two list items all together in a single column each and they're still not lining up. I will try each list item getting its own cell - which should remedy the problem of when there isn't a corresponding item in the next column over.

Still want to have the bullets, but not sure how to do it: Can it be done with something like 'text-decoration: disc' (or whatever it actually should be) applied to the cells.. or would I do <ul><li> ITEM 1</ul></li> within each cell?
I'm concerned that in the event of wrapping, the bullets will align with the bottom line of text rather than the top.... I saw this happening in IE.
I really need to get this finished in 24 hrs, I don't care if the HTML is a mess!

Thanks.

alt131

7:46 am on Nov 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My next plan is to do a TABLE. Does this sound feasible?

The wrong person to ask, greygoose - I believe in the semantic web, so unless this is tabular data my response has to "no" in terms of well-crafted code.

I will try each list item getting its own cell - which should remedy the problem of when there isn't a corresponding item in the next column over.
Yes it will remedy the alignment problem, but you are no longer coding a list and create the issue you recognise in
Can it be done with something like 'text-decoration: disc'

I think what you are thinking of is display:list-item - the default for a <ul>/<ol> and which should produce a bullet when applied to something else. Unfortunately it is not well supported, so not a real solution.

Another option I trialled was the pseudo element

:before
, along with a styled
content: "."
, but side-tracked myself investigating chaining with
:first-letter
to produce the different coloured "bullets" using as little code as possible.

That was the reason behind suggesting &bull; - not ideal, but can be styled to look like a bullet for ie, but if combined with a pseudo element can be given display:none so it doesn't affect accessibility devices. However, that may require some structural mark-up.

I'm concerned that in the event of wrapping, the bullets will align with the bottom line of text rather than the top.... I saw this happening in IE
As stated in my first post, ie respects
vertical-align
which solved the trouble. Unfortunately that won't work for ff or winsafari (or opera if memory serves), so again, not a real solution.

The margin technique finally worked in IE, but each line contained only one word, which may not suit the client.. also didn't quite display properly in FF in the end.
The display discrepancy may be due to the way ie handles margins (and padding). Hence my suggestion to use proper positioning.

It would be easier if you would post some "almost working code", but I spent some time on this yesterday, so I'll dig through the examples and post some possible solutions shortly. No need for [too] messy html ;)

alt131

10:13 am on Nov 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is the most simple solution I have. It is imperfect in terms of structural mark-up and accessibility, but a compromise of the worst possible features, and I think cleaner than positioning.

It could be further tidied but it is quite a bit of work to overcome the variations on :before. In the end the span - which was intended to be hidden with display:none and only used by ie, has been used for all because ff has too many difficulties with the pseudo elements (:first-letter, :first-line and :before) - which make this a breeze in winSafari. However, better than a table ;)


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>My Title</title>
<style type="text/css">
ul {
width:550px;
}
li {
display:inline;
float:left;
width: 50%;
height:35px; /*dimension to accommodate tallest wrap */
font-size:14px; /* balance font-size and line-height with height of the li*/
line-height:16px;
border:1px solid blue;/*for testing */
border-style:solid none;
}
/*This could be first-letter, but ff refuses to play nice*/
li span {
float:left;
color: orange; /*gap to avoid triggering a smiley when posted */
margin-right:5px;
font-size:30px;
height:35px; /*same as height of li*/
border:1px solid red; /*for testing*/
}
</style>
</head>
<body>
<h2>My List</h2>
<ul>
<li><span>&bull;</span>List Item</li>
<li><span>&bull;</span>List Item that is long enough to wrap and wrap and wrap</li>
<li><span>&bull;</span>List Item that is long enough to wrap and wrap and wrap</li>
<li><span>&bull;</span>List Item</li>
<li><span>&bull;</span>List Item</li>
<li><span>&bull;</span>List Item that is long enough to wrap and wrap and wrap </li>
<li><span>&bull;</span>Last List Item </li>
</ul>
</body>
</html>

Tested on [pc] ie6&7, Opera9.27&9.6, ff2&3, winSafari.

swa66

7:33 pm on Nov 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've not played with alt131's code but a solution to get it more semantic would be to use graphical background images to create the bullets (allowing to have them be a bit more fancy and allowing positioning at will as well).

greygoose

5:01 am on Nov 17, 2008 (gmt 0)

10+ Year Member



Thanks for the thorough replies!
I was in the middle of table making when I got your example, alt131, and so didn't get around to using it. The bullets were kind of large and I was worried about all the little adjustments I'd need to make to fit my long list items. Karma boomed loud and clear, however, and I ended up having to scrap the multi-celled table idea due to validation errors and their ensuing corrections.

I reverted to just having my separate lists in a single row with 2 columns.
It works fine.. should have done it from the start and saved myself a lot of grief. One list doesn't quite balance out in FF, but we'll have to live with it.

What's so terrible about tables anyway?!