Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

on IE 7, empty div will have height when width is specified

Question posted by: liketofindoutwhy (Guest) on June 27th, 2008 07:19 PM
it seems that on Firefox and IE, even for standard compliance mode,
the following code will give different result:


<div style="border:1px solid orange; width:300px"></div>

on IE 7, the div will have a height of "line-height", but on Firefox
2, the div will have zero height.

When the width:300px is removed, then it is zero height on both IE 7
and Firefox 2...

any method to make them consistent? Zero height is wanted when the
database returns empty string for within the div. Thanks very much!

Stanimir Stamenkov's Avatar
Stanimir Stamenkov
Guest
n/a Posts
June 27th, 2008
07:19 PM
#2

Re: on IE 7, empty div will have height when width is specified
Thu, 5 Jun 2008 22:14:31 -0700 (PDT), /liketofindoutwhy/:
Quote:
it seems that on Firefox and IE, even for standard compliance mode,
the following code will give different result:
>
<div style="border:1px solid orange; width:300px"></div>
>
on IE 7, the div will have a height of "line-height", but on Firefox
2, the div will have zero height.
>
When the width:300px is removed, then it is zero height on both IE 7
and Firefox 2...
>
any method to make them consistent? Zero height is wanted when the
database returns empty string for within the div. Thanks very much!


Giving the DIV an explicit 'width' triggers its 'hasLayout' [1]
property in IE which makes it render quite differently from
standard-compliant.

[1] http://msdn.microsoft.com/en-us/lib...776(VS.85).aspx

--
Stanimir

dorayme's Avatar
dorayme
Guest
n/a Posts
June 27th, 2008
07:19 PM
#3

Re: on IE 7, empty div will have height when width is specified
In article <g2aiuu$911$1@registered.motzarella.org>,
Stanimir Stamenkov <s7an10@netscape.netwrote:

Quote:
Giving the DIV an explicit 'width' triggers its 'hasLayout' [1]
property in IE which makes it render quite differently from
standard-compliant.
>
[1] http://msdn.microsoft.com/en-us/lib...776(VS.85).aspx


This url appears without scrollbars in Safari 2 and iCab 4.

--
dorayme

Stanimir Stamenkov's Avatar
Stanimir Stamenkov
Guest
n/a Posts
June 27th, 2008
07:19 PM
#4

Re: on IE 7, empty div will have height when width is specified
Fri, 06 Jun 2008 16:08:47 +1000, /dorayme/:
Quote:
In article <g2aiuu$911$1@registered.motzarella.org>,
Stanimir Stamenkov <s7an10@netscape.netwrote:
>
Quote:
>Giving the DIV an explicit 'width' triggers its 'hasLayout' [1]
>property in IE which makes it render quite differently from
>standard-compliant.
>>
>[1] http://msdn.microsoft.com/en-us/lib...776(VS.85).aspx

>
This url appears without scrollbars in Safari 2 and iCab 4.


I don't know how old Safari 2 and iCab 4 are and whether they could
turn author styles off, but given the OP has IE to try with he'll be
able to read it. I'm reading it all right using SeaMonkey 1.1.9,
Opera 9.27, Safari 3.1.1 and Lynx 2.8.6rel.5 all on Windows.

--
Stanimir

dorayme's Avatar
dorayme
Guest
n/a Posts
June 27th, 2008
07:19 PM
#5

Re: on IE 7, empty div will have height when width is specified
In article <g2alot$hjg$1@registered.motzarella.org>,
Stanimir Stamenkov <s7an10@netscape.netwrote:
Quote:
Fri, 06 Jun 2008 16:08:47 +1000, /dorayme/:
Quote:
In article <g2aiuu$911$1@registered.motzarella.org>,
Stanimir Stamenkov <s7an10@netscape.netwrote:

Quote:
Quote:


This url appears without scrollbars in Safari 2 and iCab 4.

>
I don't know how old Safari 2 and iCab 4 are and whether they could
turn author styles off, but given the OP has IE to try with he'll be
able to read it. I'm reading it all right using SeaMonkey 1.1.9,
Opera 9.27, Safari 3.1.1 and Lynx 2.8.6rel.5 all on Windows.


iCab 4 is latest, Safari 2 is not latest but is good and would not turn
off author styles. No problems with other browsers. I am not too curious
given it is MS.

--
dorayme

Jonathan N. Little's Avatar
Jonathan N. Little
Guest
n/a Posts
June 27th, 2008
07:19 PM
#6

Re: on IE 7, empty div will have height when width is specified
liketofindoutwhy wrote:
Quote:
it seems that on Firefox and IE, even for standard compliance mode,
the following code will give different result:
>
>
<div style="border:1px solid orange; width:300px"></div>
>
on IE 7, the div will have a height of "line-height", but on Firefox
2, the div will have zero height.
>
When the width:300px is removed, then it is zero height on both IE 7
and Firefox 2...
>
any method to make them consistent? Zero height is wanted when the
database returns empty string for within the div. Thanks very much!
>


Ah hope that IE9 will be standards compliant? ;-)

If content is from a database, just have your server side script check
the output for content before generating the page and if there is none,
don't generate the containing DIV.

Not too advisable, but you could use JavaScript to scan the collection
of DIVs and delete or hide any without content when page loads. Then
only IE users with JavaScript disable will see the empty boxes.

Or lastly, live with the empty boxes on IE...

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

liketofindoutwhy's Avatar
liketofindoutwhy
Guest
n/a Posts
June 27th, 2008
07:19 PM
#7

Re: on IE 7, empty div will have height when width is specified
hm, it seems like there are 2 solutions:

1) don't show the div at all when the string is empty by using PHP
(the border was only for debug purpose and not needed)

2) or, this div is inside another div with width of 600px, so i can
set this inner div to have no width, but just a margin-right of 50px
or something like that.

I tested both solutions and they worked in both IE 7 and Firefox 2.


liketofindoutwhy's Avatar
liketofindoutwhy
Guest
n/a Posts
June 27th, 2008
07:19 PM
#8

Re: on IE 7, empty div will have height when width is specified
so dorayme is in austalia? do you get to play a lot of sports
there? what do you do over the weekends?

dorayme's Avatar
dorayme
Guest
n/a Posts
June 27th, 2008
07:19 PM
#9

Re: on IE 7, empty div will have height when width is specified
In article
<b14f11f7-f62f-480d-bdaf-069dd919c2a2@m45g2000hsb.googlegroups.com>,
liketofindoutwhy <liketofindoutwhy@gmail.comwrote:
Quote:
so dorayme is in austalia? do you get to play a lot of sports
there?


No, I played more sport when I was in England, in bad weather and clouds
and snow and my right foot still has big boney top where soccer ball
kept hitting it and flying off at great speed, sometimes into net and me
pleased and team pleased and 9 out of crowd of 18 people pleased...
Quote:
what do you do over the weekends?


I cry and drink a lot of tea.

--
dorayme

liketofindoutwhy's Avatar
liketofindoutwhy
Guest
n/a Posts
June 27th, 2008
07:19 PM
#10

Re: on IE 7, empty div will have height when width is specified
On Jun 6, 3:41 pm, dorayme <doraymeRidT...@optusnet.com.auwrote:
Quote:
In article
<b14f11f7-f62f-480d-bdaf-069dd919c...@m45g2000hsb.googlegroups.com>,
>
liketofindoutwhy <liketofindout...@gmail.comwrote:
Quote:
so dorayme is in austalia? do you get to play a lot of sports
there?

>
No, I played more sport when I was in England, in bad weather and clouds
and snow and my right foot still has big boney top where soccer ball
kept hitting it and flying off at great speed, sometimes into net and me
pleased and team pleased and 9 out of crowd of 18 people pleased...
>
Quote:
what do you do over the weekends?

>
I cry and drink a lot of tea.
>


do how come you cry in the weekends? for one thing, you know CSS well
and seems to enjoy life.

dorayme's Avatar
dorayme
Guest
n/a Posts
June 27th, 2008
07:19 PM
#11

Re: on IE 7, empty div will have height when width is specified
In article
<5737bb2a-14ff-49f9-abde-7a20c8897be8@l64g2000hse.googlegroups.com>,
liketofindoutwhy <liketofindoutwhy@gmail.comwrote:
Quote:
On Jun 6, 3:41 pm, dorayme wrote:
Quote:
liketofindoutwhy wrote:

....
Quote:
Quote:
Quote:
what do you do over the weekends?


I cry and drink a lot of tea.

>
do how come you cry in the weekends? for one thing, you know CSS well
and seems to enjoy life.


Because, on the weekends, I feel like one or the other of two people who
enjoyed life but who were finished off by the brute, Zampanò in the
film, La Strada. Namely, Gelsomina and Il 'Matto'-The 'Fool'.

--
dorayme

 
Not the answer you were looking for? Post your question . . .
190,081 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors