HighDots Forums  

<div> expands dramatically due to change in font-size property

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss <div> expands dramatically due to change in font-size property in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
skeeterbug
 
Posts: n/a

Default <div> expands dramatically due to change in font-size property - 01-11-2005 , 04:26 PM






please see

http://www.geocities.com/operationsengineer1/test.htm

for an idea of how i want my logo header div to be layed out.

when i went to resize "Test" to 2em (from 1em), this is what
happened...

http://www.geocities.com/operationsengineer1/test1.htm

the div expanded to twice the size, too!

this was totally unexpected to me, however, it displays this way in
both ie6 and ff1 so i think it is rendering correctly and i've coded
something incorrectly.

any guidance would be appreciated.


Reply With Quote
  #2  
Old   
skeeterbug
 
Posts: n/a

Default Re: <div> expands dramatically due to change in font-size property - 01-11-2005 , 04:33 PM






i should say the div expands proportionally to an increase in the
font-size declaration of that div.

at font-size: 1em; everything is great.

at font-size: 2em; there is a double - even outside my "container" div
which houses the logo header div..


Reply With Quote
  #3  
Old   
Jan Roland Eriksson
 
Posts: n/a

Default Re: <div> expands dramatically due to change in font-size property - 01-11-2005 , 04:50 PM



On 11 Jan 2005 13:26:28 -0800, "skeeterbug" <jskeith1 (AT) san (DOT) rr.com> wrote:

Quote:
please see
http://www.geocities.com/operationsengineer1/test.htm
for an idea of how i want my logo header div to be layed out.
when i went to resize "Test" to 2em (from 1em), this is what
happened...
http://www.geocities.com/operationsengineer1/test1.htm
the div expanded to twice the size, too!
Hard to tell really.

Your "strict" doctype declaration will not be picked up by the doctype
sniffers when you serve a page from geocities, so anything that comes
out of that place will be rendered in "quirks" mode regardless of what
you do to try to get it right.

There is no such thing as a free lunch
(or a _free_ www server for that matter :-)

--
Rex




Reply With Quote
  #4  
Old   
Steve Pugh
 
Posts: n/a

Default Re: <div> expands dramatically due to change in font-size property - 01-11-2005 , 04:55 PM



"skeeterbug" <jskeith1 (AT) san (DOT) rr.com> wrote:

Quote:
http://www.geocities.com/operationsengineer1/test.htm

for an idea of how i want my logo header div to be layed out.

when i went to resize "Test" to 2em (from 1em), this is what
happened...

http://www.geocities.com/operationsengineer1/test1.htm

the div expanded to twice the size, too!
Makes sense. You've told the div to be 6 times the font-size and then
you've doubled the font size.

When a length is defined in em the value of 1em varies on the property
being defined:
For font-size 1em = the font-size of the parent element.
For all other properties 1em = the font size of the current element.

Steve



Reply With Quote
  #5  
Old   
Harlan Messinger
 
Posts: n/a

Default Re: <div> expands dramatically due to change in font-size property - 01-11-2005 , 05:13 PM




"skeeterbug" <jskeith1 (AT) san (DOT) rr.com> wrote

Quote:
please see

http://www.geocities.com/operationsengineer1/test.htm

for an idea of how i want my logo header div to be layed out.

when i went to resize "Test" to 2em (from 1em), this is what
happened...

http://www.geocities.com/operationsengineer1/test1.htm

the div expanded to twice the size, too!

this was totally unexpected to me, however, it displays this way in
both ie6 and ff1 so i think it is rendering correctly and i've coded
something incorrectly.
The height of the DIV is 6em, which means 6 times "the computed value of the
'font-size' property of the element on which it is used [i.e., the DIV]." If
you double the DIV's font-size property from 1em to 2em, you've doubled its
computed value, which means you've doubled any value that's defined in terms
of that computed value. In other words: this is the correct behavior.



Reply With Quote
  #6  
Old   
Disco Octopus
 
Posts: n/a

Default Re: <div> expands dramatically due to change in font-size property - 01-11-2005 , 08:00 PM



skeeterbug wrote :
Quote:
please see

http://www.geocities.com/operationsengineer1/test.htm

for an idea of how i want my logo header div to be layed out.

when i went to resize "Test" to 2em (from 1em), this is what
happened...

http://www.geocities.com/operationsengineer1/test1.htm

the div expanded to twice the size, too!

this was totally unexpected to me, however, it displays this way in
both ie6 and ff1 so i think it is rendering correctly and i've coded
something incorrectly.

any guidance would be appreciated.
Not sure if this is what you should be considering, but take a look
here anyway....

http://mycoolfish.com/t/thing.html


All the divs are using the same class. They each have been applied the
same text size in /em/

resize the text and see what happens. This behaviour is because they
are each nested and inheret each others parent size.
So... the outermost uses 1.2em of its parent (the body) - 100%. the
first ensted element uses 1.2 em of its parent (which is already using
1.2em of its parent)... and so on.

play around and see what happens when you make the em size 1em, 1.2 em,
and .9em.

All expected results because of the nesting.

This may lead you into reason of the behaviour of your page.

Hope it helps.

--
dance with children in the rain



Reply With Quote
  #7  
Old   
skeeterbug
 
Posts: n/a

Default Re: <div> expands dramatically due to change in font-size property - 01-11-2005 , 08:28 PM



Quote:
Makes sense. You've told the div to be 6 times the font-size and then
you've doubled the font size.
that makes sense aqs you've explained it, but that IS NOT what i was
trying to do. i was trying to make the div 6em - period. well, you
know, at the normal text size in a browser.

i want em so that its size can be adjusted when folks adjust their
browser's text size.

i then want to be code different font-sizes within my 6em div.

i *thought* that is what i did, however, i'm obviously wrong.

i still don't see where i went wrong. can anyone help?

tia...

Quote:
When a length is defined in em the value of 1em varies on the
property
being defined:
For font-size 1em = the font-size of the parent element.
For all other properties 1em = the font size of the current element.

Steve


Reply With Quote
  #8  
Old   
Steve Pugh
 
Posts: n/a

Default Re: <div> expands dramatically due to change in font-size property - 01-12-2005 , 03:43 AM



"skeeterbug" <jskeith1 (AT) san (DOT) rr.com> wrote:

Quote:
Makes sense. You've told the div to be 6 times the font-size and then
you've doubled the font size.

that makes sense aqs you've explained it, but that IS NOT what i was
trying to do. i was trying to make the div 6em - period. well, you
know, at the normal text size in a browser.
Then make it 3em.

height of element relative to own font size = height of element
relative to default font size / element's own font size relative to
default font size*

3 = 6 / 2

*If there was an inbetween element with font-size 1.2em you would need
to take that into account as well. So instead of dividing by 2 you
would divide by 1.2 because he computed value for the element's
font-size would be 1.2*2 = 2.4 times the browser default.

Quote:
i want em so that its size can be adjusted when folks adjust their
browser's text size.
How much text will you have in your header? As the font size increases
the text may wrap onto a second line, and then onto a third. In this
case it may spill out of the box you're providing. Instead of setting
a height set a bottom padding.

Quote:
i still don't see where i went wrong. can anyone help?
Is there something missing from the description I gave and which you
quoted (and Harlan gives the same explanation in more technical
terms.):

Quote:
When a length is defined in em the value of 1em varies on the
property being defined:
For font-size 1em = the font-size of the parent element.
For all other properties 1em = the font size of the current element.
Steve



Reply With Quote
  #9  
Old   
skeeterbug
 
Posts: n/a

Default Re: <div> expands dramatically due to change in font-size property - 01-12-2005 , 10:03 AM



steve, thanks. i did exactly that. the strange thing is i was working
on a different layout and was able to adjust my text size in the header
w/o the header changing dimensions. that's why this caught me off
guard.

anyway, i have "case a" and i have "case b," so i guess i just need to
play around with the code and figure out what determines case a and
what determines case b.
when i have time to figure it out, i'll post the answer here.


Reply With Quote
  #10  
Old   
Frances Del Rio
 
Posts: n/a

Default Re: <div> expands dramatically due to change in font-size property - 01-18-2005 , 01:43 PM





skeeterbug wrote:

Quote:
please see

http://www.geocities.com/operationsengineer1/test.htm

for an idea of how i want my logo header div to be layed out.

when i went to resize "Test" to 2em (from 1em), this is what
happened...

http://www.geocities.com/operationsengineer1/test1.htm

the div expanded to twice the size, too!

this was totally unexpected to me, however, it displays this way in
both ie6 and ff1 so i think it is rendering correctly and i've coded
something incorrectly.
how about specifying a width for the <div>?

for example, width:300px;

someone correct me if I'm wrong, but it seems to me if you specify a
width <div> will always be same width regardless of font size..

HTH... Frances





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.