11 replies [Last post]
dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 3 years 16 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

Anyone else had this problem?

In IE5, something like:

<div style="margin-left: 150px;">
  <div style="width:33%; float:left;">stuff</div>
  <div style="width:33%; float:left;">stuff</div>
  <div style="width:33%; float:left;">stuff</div>
</div>

seems to set the widths of the floats to a percentage of the browser window, not the containing DIV.

Workarounds? Thoughts?

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 17 hours 15 min ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

doctype

Hi DJomp,
The magic of DOCTYPES will save you.
Try<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
as the very first thing in your code, before the HTML tag.

dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 3 years 16 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

IE5 and percentage widths

I have transitional as my current doctype... will try the strict one, pray that it helps!

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 3 years 16 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

IE5 and percentage widths

Nope, that didn't help, unfortunately. Maybe IE5 doesn't pick them up?

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 17 hours 15 min ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

IE5 and percentage widths

Hi DJomp,
Nothing can fix ie5 :roll:

IE6 on win works with the doctype.
Doctype switching (going between standard and quirk mode) came into effect to control the differences between browsers of the ie 5 era and the newer rendering of ie6 etc.
Here's some more info:
Doctype switching and standards compliance: An overview

Doctypes and their respective layout mode

dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 3 years 16 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

IE5 and percentage widths

Reading something like that almost makes you want to go into quirk mode... but almost, I think I like using the proper standards. Besides I bet there are browsers out there that don't support quirk mode, or have a completely different one. Bah.

All it means now is that very little of my site is horizontal... all my table-like thumbnails are now in a vertical list as I can't guarantee the width of anything (not even a table!) Still means more room for words about each gallery/picture I suppose...

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

Sven
Sven's picture
Offline
Enthusiast
Brisbane, Australia
Last seen: 11 years 50 weeks ago
Brisbane, Australia
Timezone: GMT+10
Joined: 2003-03-12
Posts: 166
Points: 0

IE5 and percentage widths

If it's appropriate for the content, you could always use another measure for the widths of the divs: pixels, ems, whatever, and hope you don't encounter a similar quirk with one of those Smile

dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 3 years 16 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

IE5 and percentage widths

Have just had a brainwave.

As my site is written in PHP, I can have a small script to detect the browser that is being used; if I know it'll support the DTD it can link to one style sheet; if I don't think it will (eg unknown browser) or know it won't (IE5, NN4) then I link to a standard one.

I remember sites not long ago redirecting you based on your browser. Now I see why... Laughing out loud

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 17 hours 15 min ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

Browser detecting scripts

Hi DJomp,
Although I have used php scripts to detect users browsers and even have one available to download, the practice is not recommended.
You have to keep modifying your script to keep up with new browsers otherwise they get fed limited style sheets.
Another option would be to use something like
@import url(styles.css);which is ignored by Netscape 4, or child selectors:
body > div{margin-left:150px;} which is ignored by Netscape 4 and IE 5/5.5
Hope that helps.

dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 3 years 16 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

IE5 and percentage widths

Given at the moment everyone is getting the reduced style sheet version, it would be an improvement!

It was just a brief thought this morning; I would consider setting it to 'change' the style sheet for the older, incompatiable browsers, and cross fingers than new browsers could cope. Although that's probably just as bad.

Some nice script there, I do have some stat logging at the moment - the thing that interested me was the screen resolution, but that doesn't seem to be in the script, is that done through some other PHP means or something else? I've never found a way of finding that out.

I think I need to get a lot of browsers and find which cause the problems, then the child selectors may be useful.

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 17 hours 15 min ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

IE5 and percentage widths

Thanks DJomp,
Yes the screen resolution is done with javascript.

<script type="text/javascript" language="JavaScript1.2">
document.write("Your screen resolution is: "+screen.width +" * "+screen.height);
</script>

The hard part was getting the values from the server side javascript and passing it back to php on the server to insert into the database. Wink

maniac
maniac's picture
Offline
newbie
Last seen: 10 years 34 weeks ago
Joined: 2004-08-03
Posts: 3
Points: 0

Re: doctype

Tony wrote:
Hi DJomp,
The magic of DOCTYPES will save you.
Try<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
as the very first thing in your code, before the HTML tag.

Indeed !

I had a similar problem,. quick search on the forum, found your post, made the change and BAM! Problem fixed Laughing out loud

Thanks for the help Smile