Click to See Complete Forum and Search --> : List wrapping around table, cross-browser


Thatsid
01-19-2007, 10:23 AM
I'm having trouble in creating a list that positions next to- and possibly wraps around a table, div or image and behaves well on all occasions.
This construction has the following conditions:


The document has to be XHTML 1.0 transitional
The bullets have to align properly next to the table in IE6, IE7 and Firefox 1.5.0.8 (most commonly used FF-version)
The content has to wrap around the element. That's why a 2-cell table, with the image placed in the left cell and the text and list in the right cell, is no option.
This content is to be maintained in a Content Management System, so it's not allowed to place extra HTML-tags or classes in or around the list to influence it's behavior. All styles have to be placed in the standard classes for the <ul> and <li>, as you can see in the stylesheet in the header. The same basic code has to be working also without standing next to the table element.

Find the used styles in the header-tag. In the comments in the classes you can see some things we tested, but not succeded in.

Download the sourcecode (http://www.thats-id.nl/test_list_wrapping/test_list_wrapping.zip)
See the testpage (http://www.thats-id.nl/test_list_wrapping/)

Code of the page:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>test bullets next to image</title>

<style type="text/css">
<!--
p, a, li {font-family:arial;font-size:11px;}

ul {
list-style:none;
margin: 0; /* UL ALIGNS TO LEFT OF DOCUMENT */
/*NOT WORKING > position: relative; ALIGN LI's RELATIVE TO PREVIOUS ELEMENTS *
/*NOT WORKING > left: 20px; SPACE BETWEEN PREVIOUS ELEMENT AND LI */
padding: 0px 0px;
border: 0px none;
/*NOT WORKING > overflow:hidden; UL STARTS AT RELATIVE POSITION */
}
ul li {
margin:0;
padding:0;
padding-left:15px;
background-image:url(list_item_bullet.gif);
background-repeat:no-repeat;
background-position:0px 8px;
border:1px solid red;
/*NOT WORKING > position: relative; GIVING LI A RELATIVE POS. MAKES IT ALIGN TO UL */
width:100%; /* makes the bullets align next to the table. */
}
-->
</style>
</head>


<body style="margin:10px; padding:0;">
<!-- Start: container for content -->
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" style="border:2px solid green;">
<h2>list in text wrapping around table</h2>

<!-- Start: table with media element, like visual and subscript -->
<table width="239" height="179" border="0" align="left" cellpadding="0" cellspacing="0" style="margin-right:15px; margin-bottom:10px; border:1px solid blue;">
<tr>
<td>[place for image] </td>
</tr>
<tr>
<td>[place for subscript] </td>
</tr>
</table>
<!-- End: table with media element, like visual and subscript -->
<!-- Start: text and bullets -->
<p>text</p>
<ul>
<li>bullet item1</li>
<li>bullet item2</li>
<li>bullet item3</li>
<li>bullet item4</li>
<li>bullet item5</li>
<li>bullet item6</li>
<li>bullet item7</li>
<li>bullet item8</li>
</ul>
<p>text</p>
<p>text</p>
<ul>
<li>bullet item1</li>
<li>bullet item2</li>
<li>bullet item3</li>
</ul>
<p>text</p>

<!-- End: text and bullets -->

</td>
</tr>
</table>
<!-- End: container for content -->

</body>
</html>

KDLA
01-19-2007, 11:28 AM
I quite didn't understand your post....
Can you create classes in the stylesheet (or inline styles) and apply them in the HTML? If so....
Place the height of your table in the height of the neighboring <ul>. For the next paragraph, use clear: left.

KDLA

toicontien
01-19-2007, 11:41 AM
I've found that UL and OL elements do not wrap like text around floated elements. The floated element in this case is the table with align="left". It's not a bug. The list will have it's width reduced to the space between the table and the right edge of the block that contains the UL. When the UL gets below the table, the UL will remain the same width, causing the LI elements to not wrap underneath the table. This appears to be standard behavior cross-browser.

If you want the list bullets to not overlap the table, you must either change the list-style-position property of the UL to inside, or I think you can use left padding. If not, you'll need to explicitly set the width of the UL or put a left margin on the UL equal to the table's width, then put left padding on the UL so the bullets do not overlap table.

Thatsid
01-26-2007, 04:22 AM
Hi guys,

See the final solution at:
http://www.codingforums.com/showthread.php?p=525109#post525109

greetings,
Jorn