473,410 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

IE bug: floated <LI> in 100% width <UL> wraps to next line

Hi,

Got an unordered list with 100% width, with 5 list items of 20% width
styled to fill the width of the container element.

Renders fine in Mozilla, but when you change the size of the window in
IE, the last item in the list has a nasty tendency to wrap down to the
next line (and stay there).

I can hack it (imperfectly) by setting the width of the list items to
19.9%, but I was wondering whether anyone has a more elegant solution
that they might be kind enough to direct me to?

Thanks in advance.

Example HTML to reproduce:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>CSS test</title>
<style>
body
{
font-size: 80%;
font-family: Tahoma, Verdana;
margin: 0;
padding: 0;
}
#globalnav
{
width: 100%;
margin: 0;
padding: 0;
}
li.globalheading
{
width: 20%;
}
#globalnav li
{
list-style: none;
display: inline;
background: yellow;
height: 20px;
}
#globalnav a
{
text-decoration: none;
display: block;
text-align: center;
}
</style>
</head>
<body>
<ul id="globalnav">
<li class="globalheading">
<a href="http://www.foo.com/">Group</a>
</li>
<li class="globalheading">
<a href="http://www.foo.com/australia/">Australia</a>
</li>
<li class="globalheading">
<a href="http://www.foo.com/asiapacific/">Pacific Asia
Central Europe</a>
</li>
<li class="globalheading">
<a href="http://www.foousa.com/">the Americas</a>
</li>
<li class="globalheading">
<a href="http://www.foo.com/europe/">Europe</a>
</li>
</ul>
</body>
</html>
Jul 21 '05 #1
4 9509
Els
Matt wrote:
Hi,
Hello,
Got an unordered list with 100% width, with 5 list items of
20% width styled to fill the width of the container
element.

Renders fine in Mozilla,
Really? I looked at it in Firefox, and it gives a vertical
list, not horizontal.
but when you change the size of
the window in IE, the last item in the list has a nasty
tendency to wrap down to the next line (and stay there).

I can hack it (imperfectly) by setting the width of the
list items to 19.9%, but I was wondering whether anyone has
a more elegant solution that they might be kind enough to
direct me to?
If you only want it to work in IE, then the 19.9% is the way
to go. If you want it to work in more browsers, you have a
problem:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN"> <html>
This doctype without a dtd throws IE in quirksmode, which is
why it does what you want. Try this one to see what I mean:

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

[...]
li.globalheading
{
width: 20%;
}
You are giving the li element a width,
#globalnav li
{
display: inline;


and then tell it to be inline.
Inline elements don't "listen" to widths.
So your choice is either: use inline elements and don't let it
fill up the width of the container, or, use block elements and
float them.

With floated li elements you will encounter your initial
problem in IE again, and yes it's a bug, and yes, 19.9% is the
solution :-)

One thought: You said it was working in Mozilla.
Could it be that the code you last tested already had
"display:inline" replaced by "float:left" ?

In that case, this is one of those fine examples why online
examples are better than copy paste code in the message.

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jul 21 '05 #2
On 11 Feb 2005 10:08:31 -0800 Matt wrote:
Hi, Got an unordered list with 100% width, with 5 list items of 20% width
styled to fill the width of the container element. Renders fine in Mozilla, but when you change the size of the window in
IE, the last item in the list has a nasty tendency to wrap down to the
next line (and stay there). I can hack it (imperfectly) by setting the width of the list items to
19.9%, but I was wondering whether anyone has a more elegant solution
that they might be kind enough to direct me to? Thanks in advance.


<li><div>testing 1 2 3</div></li>

Now define the division instead of the "li".

List only has these properties: <li CLASS="" DIR="" ID="" LANG="" STYLE=""
TITLE="" TYPE="" VALUE=""> and all the mouse tricks.

So you can't define something it does not have to begin with.
Jul 21 '05 #3
"Richard" <An*******@127.001> wrote:
On 11 Feb 2005 10:08:31 -0800 Matt wrote:
Got an unordered list with 100% width, with 5 list items of 20% width
styled to fill the width of the container element.
Renders fine in Mozilla, but when you change the size of the window in
IE, the last item in the list has a nasty tendency to wrap down to the
next line (and stay there).

I can hack it (imperfectly) by setting the width of the list items to
19.9%, but I was wondering whether anyone has a more elegant solution
that they might be kind enough to direct me to?


Matt, please do not listen to Richard, he's an idiot and never gives
good advice.
<li><div>testing 1 2 3</div></li>

Now define the division instead of the "li".
What difference do you think that will make?
List only has these properties: <li CLASS="" DIR="" ID="" LANG="" STYLE=""
TITLE="" TYPE="" VALUE=""> and all the mouse tricks.
"all the mouse tricks"? Do you mean cartwheels and handstands?

No, you probably mean the event handlers. There, that's today's new
phrase for you to start parroting back in your garbage posts "event
handlers", say it out loud a few times if that helps you remember it.

But be careful, not all event handlers are mouse related, in fact for
accessibility reasons you're recommended to avoid device specific
events and use logical ones instead.
So you can't define something it does not have to begin with.


What are you blathering about?

This is a stylesheets newsgroup so I think it's fairly safe to assume
that Matt was setting the width via CSS, in which case the class, id
or style attributes would be perfectly capable of handling whatever he
needs.

In fact if he was setting something he wasn't allowed to we would
expect the <li>s to have their default width of 100% in all browsers
which doesn't match the dscribed problem at all.

Please refrain from giving any adviceat all until you have (a) learnt
to read the questions properly and (b) understood the basics of HTML
and CSS.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 21 '05 #4
Hi Els,
With floated li elements you will encounter your initial
problem in IE again, and yes it's a bug, and yes, 19.9% is the
solution :-)
Oh well. I'm using the '* html ...' selector hack to set it to 19.9% in
IE only, so that'll have to suffice I guess.
One thought: You said it was working in Mozilla.
Could it be that the code you last tested already had
"display:inline" replaced by "float:left" ? In that case, this is one of those fine examples why online
examples are better than copy paste code in the message.
Whoops, yes. I am a doofus. Thanks for taking the time to reply anyway.

Matt
Els wrote: Matt wrote:
Hi,


Hello,
Got an unordered list with 100% width, with 5 list items of
20% width styled to fill the width of the container
element.

Renders fine in Mozilla,


Really? I looked at it in Firefox, and it gives a vertical
list, not horizontal.
but when you change the size of
the window in IE, the last item in the list has a nasty
tendency to wrap down to the next line (and stay there).

I can hack it (imperfectly) by setting the width of the
list items to 19.9%, but I was wondering whether anyone has
a more elegant solution that they might be kind enough to
direct me to?


If you only want it to work in IE, then the 19.9% is the way
to go. If you want it to work in more browsers, you have a
problem:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN"> <html>


This doctype without a dtd throws IE in quirksmode, which is
why it does what you want. Try this one to see what I mean:

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

[...]
li.globalheading
{
width: 20%;
}


You are giving the li element a width,
#globalnav li
{
display: inline;


and then tell it to be inline.
Inline elements don't "listen" to widths.
So your choice is either: use inline elements and don't let it
fill up the width of the container, or, use block elements and
float them.

With floated li elements you will encounter your initial
problem in IE again, and yes it's a bug, and yes, 19.9% is the
solution :-)

One thought: You said it was working in Mozilla.
Could it be that the code you last tested already had
"display:inline" replaced by "float:left" ?

In that case, this is one of those fine examples why online
examples are better than copy paste code in the message.

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -


Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Michael | last post by:
This is a two-part question to which I haven't been able to find an answer anywhere else. 1. Is it possible to format the bullet/number character of the <li>? In my styles sheet, I have the <li>...
5
by: toylet | last post by:
Attached is some css codes for a website. It has 3 parts: top-bar, side-bar (on the left) and main-body. The top-bar has a mouseover menu called top-menu implemented via ul:hover. When the mouse...
19
by: CMAR | last post by:
I have the following markup. The problem is that the browser, e.g., IE6, inserts several lines of blank space between the <div> and the following table. Is there a way to minimize that vertical...
5
by: Joakim Braun | last post by:
I'd like to show tree structures using collapsible multi-level nested <ul> lists (with open/closed "disclosure triangles" as list-style-images). Something like this: <ul> <li...
24
by: JB | last post by:
Hi All, This is doing my head in! Please help. I've built a simple <ul> to serve as a menu for a page I'm working on. I have tested the menu in Mozilla Fireworks 1.5 and it's fine - nice and...
6
by: ashkaan57 | last post by:
Hi, How can I set up the styling for different levels of <ULto use different images for bullets, be indenetd differently, ... Like: .. list 1 - item 1 - item 2 .. list 2
19
by: ashkaan57 | last post by:
Hi, I have a page in a right-to-left language and I am trying to make some bulleted lists using <ul>, but it puts the bullets to the left. Is there any way I can set the bullets to be on the...
3
by: Man-wai Chang | last post by:
A 2 columns x 10 rows matrix input form <ul> <li> <ul> <li>item name 1 <li><input type="textbox" name="input_col_1_row_1"> <li><input type="textbox" name="input_col_1_row_2"> </ul> <li>
1
by: Chinsu | last post by:
<html> <head> <style> #ex { width: 700px; background: red; float: left; } a, span { display: block;
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.