Resizing text with ems
I want to be able to resize some text I have in a part of my site. What I mean is this - If the text is changed to a word that has so many letters that it exceeds the width or height of the p tag or container it is in it will automatically resize smaller to fit in. Is this possible with ems? If so I'm not sure how to implement it into my code.
Here's my container so far:-
<div id="item_container" style="border:1px solid #CCCCCC; width:152px; height:100px; float:left;">
<p id="r_text" style="float:left; width:152px; height:100px; line-height:100px; text-align:center; margin:0; padding:0; font-size:2em; font-family:Arial, Helvetica, sans-serif; font-weight:bold; color:#cccccc">EXPIRED</p>
Can I get an answer please?
em is the prefered method of sizing font because some browsers (IE) doesn't allow for pixels to be resized and therefore are not accessible.
In short by using em instead of pixel to declare your font size will not allow for dynamically altering the size of the <p> tag, what it does do is allows the browser to resize the text correctly when zooming in and out.
here is a couple of em articles:
What I need is the p tag containing the text to have it's font size resize if the font text within it exceeds it's width.
Does anyone know of any examples of this perhaps in jquery that is if regular css and html can't do it of course?
once you got the size of the string its simple to check if thats less than or equal to the size of area you want for the text.
Graphics graphics = this.CreateGraphics();
SizeF textSize = graphics.MeasureString("How long am I?", this.Font);
Cheers Ribeyed. I'll look into it.
I was wondering how does Silverlight compare to Flex in the sense of it's syntax and actually learning how to use it? Is it an RIA area where a lot of jobs are available at the moment or what?
I'm trying to learn as many different web developing languages and platforms as possible to expand my opportunities. My idea is to learn a fair bit of everything and CLAIM I know a lot about everything in my cv then if an opportunity comes up in 1 specific area hammer that area like crazy before the job starts until I have a good knowledge of it.
Next I'm thinking of learning Ajax or Silverlight which is why I'm asking.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)