• Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Resizing fonts

suityou01

Potty-trained
Joined
Jan 20, 2009
Messages
21,122
Likes received
773
Thanks received
222
Location
Clown World
FFS :tantrum:

Total brain blockage

I want a div, to be a percentage of page width. I want the text in the child divs to get smaller if the page is resized.

<div style="width:50%; font-size:50%;background-color:#ff0000; color:#ffffff;">
<div>Some rubbish</div>
</div>

As the page is resized, the div gets smaller, the text does not.

Help me along my merry way, I'm supposed to me on the phones this morning, not messing about with my email sig. :bang:
 
best spend your time on the phone. most folk with any sense (mind you, clients...!!!!!) have html email disabled so your lovingly crafted sig will render in plain text.
 
best spend your time on the phone. most folk with any sense (mind you, clients...!!!!!) have html email disabled so your lovingly crafted sig will render in plain text.

you've been a great help. :rolleyes:
 
I want the text in the child divs to get smaller if the page is resized.

It seems that you want the actual font size of the child div to change as you resize the page. Unless I've misunderstood what you're asking for, I don't think this would be possible without some kind of client-side scripting. Which probably wouldn't be enabled in the vast majority of HTML email clients.

I'm willing to be proven wrong though - have you ever seen this technique elsewhere without the use of client-side script? If so, pass me a URL and I'll spend a couple of minutes pulling it apart and giving you some pointers.
 
If you do it in Flash, everything will resize perfectly.

HTH.
 
I'd also love to see a solution to this as I don't believe it's workable (to my knowledge) in CSS3. Basically, the scaling (%) is applied differently to fonts than to the box model. The box model will scale to the browser real estate, fonts will scale to the default font value.

One (clumsy) way around this would be to create a vector image of the text, SVG perhaps, and apply width & height scaling to that. Bit of a hack, but without scripting... not sure it's straightforward at all.

NF - any ideas?
 
With scripting... it would work like this (Snippet adapted from here):
Code:
<html>
<head>
<script type="text/javascript">
<!--
function scale()
{
var sizer = "12em";
var smallest = "9px";
var ww = document.body.clientWidth;
var aim = ww / (parseInt(sizer));
if (aim >= parseInt(smallest))
{document.body.style.fontSize = aim + "px";}
else
{document.body.style.fontSize = parseInt(smallest) + "px";}
}

-->
</script>
</head>
<body onload="scale();" onresize="scale();">
<div style="text-align: justify; width: 50%">
Some text here Some text here Some text here 
Some text here Some text here Some text here 
Some text here Some text here Some text here 
Some text here Some text here Some text here 
</div>
</body>
</html>
 
Last edited: 10:37
HTML email is the way forward. I hate getting text-only emails... it's 2009 for crying out loud, we're not working on some Compuserve BBS.

Anyway... it sounds like a bad idea. I like HTML emails, but if the email starts 'animating' as I resize my email window I'm going to be put off. Don't you want your sig to be sized appropriately compared to the font used in your email?
 

Advertisers

Back
Top