Forum Moderators: not2easy

Message Too Old, No Replies

Using the browser to increase font size breaks divs.

         

Mark_l

4:37 pm on Jun 8, 2006 (gmt 0)

10+ Year Member



Hi people,

I dont usually post on forums but I have a problem that I cant find the answer too!

Im experienced in CSS but this little problem has been annoying me for a while!

Say I have a div 100px wide by 100px deep with some text inside. In IE when you increase the font size the div expands because of the larger font (even though its a set width and height) BUT BUT BUT... in Firefox the text flows out and over the edges of the div and the div stays the set width and height applied to it?

How do I make firefox expand in size like IE does?

Ta

Mark

Fotiman

4:48 pm on Jun 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You don't. Firefox is behaving correctly according to the spec [w3.org]. IE is, as usual, doing it's own thing.

Rather than giving your item a fixed height, you might consider a more fluid layout that allows users to size the text to their comfort level.

PS- Welcome! :)

Mark_l

12:01 pm on Jun 9, 2006 (gmt 0)

10+ Year Member



mmm, then i still have the problem! ;-)

Say I have a container Div and insied 2 more divs. If one div has a h1 h2 etc in, how do I make the other div stretch to the height of the other div?

Ive tried height : 100%, ive tried one of those 'clearing' divs but I just cant seem to make the other div grow to the same height as the other with the content?

Ta

Mark

adb64

1:19 pm on Jun 9, 2006 (gmt 0)

10+ Year Member



Last I had more or less the same problem, see [webmasterworld.com...] I had a DIV with two floating DIVS next to each other inside it and I wanted a border between them with the height of the longest of the two columns, but couldn't make it work using CSS. With the links given in the above mentioned thread I wasn't able to get it working. So I'm also interested in a solution.

Fotiman

4:12 pm on Jun 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You could try the One True Layout [positioniseverything.net] approach for equal height columns. Alternatively, you could use the Faux Columns technique, described on the "A List Apart" website (unfortunately, links to this site are not permitted in this forum).

adb64

7:59 pm on Jun 11, 2006 (gmt 0)

10+ Year Member



Fotiman,

Thanks for the link. It looks promising at first sight.
I will dig deeper into it so see if it will fit my needs.

Arjan

snair

12:08 am on Jun 12, 2006 (gmt 0)

10+ Year Member



Can't you just set the div dimensions in ems? That should expand in both IE and Firefox when you increase the font size.

Mark_l

9:26 am on Jun 12, 2006 (gmt 0)

10+ Year Member



No, if you set the div to be 10em thats a fixed height, so when you increase the font size in firefiw the copy flows over the edge - in IE the div expands which i now know is 'wrong' but, its what I need FF to do!

snair

4:06 pm on Jun 12, 2006 (gmt 0)

10+ Year Member



Hmmm, that's strange, because when I tried this with ems, the div does expand when I increase the font size with FF.

Here's my test.

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>div em test</title>
</head>
<body>
<div style="background:#ccc; width: 5em; height: 5em;">A bunch of text.</div>
</body>
</html>

You just have to make sure your height is long enough to enclose the text initially. If it is, then the <div> will expand and enclose the text.

The other alternative is to simply not declare a width or height and the <div> will naturally enclose the text.

Hope this helps!

Mark_l

4:58 pm on Jun 12, 2006 (gmt 0)

10+ Year Member



snair, your right. That solves one problem. But not my initial problem.....

One div that holds 2 divs floated left and right. The one on the left has text in and I want the one on the right to expand in height inline with the one on the left.

snair

4:46 pm on Jun 13, 2006 (gmt 0)

10+ Year Member



ah....

yeah, unfortunately there's no surefire way to do that.

I would recommend doing what Fotiman suggests and try out the Faux Columns technique.

Best of luck!

doodlebee

4:14 pm on Jun 15, 2006 (gmt 0)

10+ Year Member



One div that holds 2 divs floated left and right. The one on the left has text in and I want the one on the right to expand in height inline with the one on the left.

and

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>div em test</title>
</head>
<body>
<div style="background:#ccc; width: 5em; height: 5em;">A bunch of text.</div>
</body>
</html>

Off the top of my head (and this isn't tested out, so I'm not sure how well it would work, but it may be a starting point!) - what if you had an outer wrapping div, set with a background color of red (for example). Then you have your left hand column in there, floated left, and set at 100% of the outer wrapping div - background color of gray. Then add in your clearing thing for the float at the bottom of the wrapping div.

In this scenario, whichever side has the most content will cause the outer wrapping div to stretch to fit it - thus expanding your red (right side) content. The left, being at 100% height of the encapsulating div, would expand to 100% height, thus making *both* cooumns stretch to the length you want.

Now, I know there's going to be issues with this in IE, but I think that can be wroked out with conditional comments (in fact, I think I may have soemthing like this in my "CSS playing" files" - I'll have to look)

But hopefully that'll get you started :)

doodlebee

4:22 pm on Jun 15, 2006 (gmt 0)

10+ Year Member



ooo...by the way, I found this link [fu2k.org] in my bookmarks, which might also provide some assistance with what you need!

4css

5:44 pm on Jun 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



try this out:

html, body {font-size: 100.01%;}

This is a trick that BigJohn from Pie taught me a long time ago, and has worked great. I just answered the same thing on another forum today. And someone else posted the following quote:

From: css-discuss

Simply put, IE for Windows' relative font size inheritance cascade is broken. The simplest workaround is to not use relative sizes, such as using keywords instead, except on base level containers. If you find it necessary to size through cascade, you'll find % works more reliably than ems. If you prefer using ems to %, then at least set the initial size using % instead, thus: html {font-size: 100.01%;} or body {font-size: 100.01%;} . This eliminates most size inheritance errors. Using 100.01% instead of 100% avoids size inheritance bugs in some versions of Opera.

Also, it is best to work in ff etc. first and then tweak in IE.