3 replies [Last post]
Langer
Offline
Regular
Last seen: 13 years 38 weeks ago
Timezone: GMT+1
Joined: 2004-06-25
Posts: 24
Points: 0

I have converted the font size in my CSS from px to %.

However, text in tables seems to be repeatedly inheriting the % font size and displaying at reduced sizes.

I have attached a simple html page to show the effect.

If you change the font size in the classes back to pixels (12px & 11px) you will see the correct display I want.

Any answers are great appreciated.

Regards

firstreflex
firstreflex's picture
Offline
Enthusiast
Brooklyn USA
Last seen: 13 years 40 weeks ago
Brooklyn USA
Timezone: GMT-5
Joined: 2003-10-21
Posts: 104
Points: 0

font size (px to %) sizing problem

I'm not really clear as to how you want it to look but I would think something like this should work.

body{	 
	font-size:75%; 
} 
table { 
	font-size:1em; /*For IE5*/ 
} 
.fontSize1 { 
	font-size:1em; 
} 
.fontSize2 { 
	font-size:1.1em; 
}

Langer
Offline
Regular
Last seen: 13 years 38 weeks ago
Timezone: GMT+1
Joined: 2004-06-25
Posts: 24
Points: 0

font size (px to %) sizing problem

Firstly thank you for you reply.

I should have been a little more clear in what I am asking.

I currently have a site with an external style sheet. I am trying to convert the font size from px to % to allow the user to modify the font size via the browser if required.

In my style sheet I have classes to define standard and smaller font size.

If all font size is defined in pixels - no problems

However: - If I covert to %, I think the problem I have, is that when I add a text (with a class size of 75%) to a table (with a class font size defined at 75%) I am getting text which displays at 75% of 75%, ie very very small.

This conflict is happening across the site. I need to be able to control the size of the font with the existing classes regardless of where the font is. Or an understand of what is happening and the best solution for it.

With the solution that you offered, fontSize2 is the class I have, which defines smaller font size. Yes this will give me a small font size within a table with a font size of 75%. But will display as larger text outside of the table.

Also, is it common to use % and em together for font sizes?

I hope this make sense. I know these things can be very difficult to get across some time.

Regards

Langer

obsidian
Offline
Enthusiast
South Carolina
Last seen: 14 years 7 weeks ago
South Carolina
Joined: 2004-08-15
Posts: 136
Points: 0

font size (px to %) sizing problem

I think I see what you're asking... as a newbie, I don't want to show too much ignorance, but I have been playing with percentages, too, and I know that any time you add a percentage, it automatically is applied to any other imbedded tags within the one you have adjusted. Hence, if you put another percentage within those tags, you need to adjust accordingly. If you are within a 75% tag, I've had to call a 125% font-size in some cases to get back to normal size within tags inside that div. Also, if I want to go a tad smaller, I have to call 90% rather than another 75%... etc.

Hope this helps

You can't win, you can't lose, you can't break even. You can't even get out of the game!