faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 3 people (100%) answered Yes
Recently 3 of 3 people (100%) answered Yes

Entry

How can i code for all window or browser sizes so that my web page text won't appear too big or smal

Apr 7th, 2008 22:54
ha mo, Klaus Bolwin, Nakita Jones,


first of all, all dimensions and positions for the HTML-elements must be
given in relative values (%). To scale the text, use the following
function, which can be called by an onload event in the body tag.
Assuming a font size of 14pt in a window of 1152px width:
function setfont()
{
iBreite = (document.all) ?
document.documentElement.offsetWidth:window.innerWidth;
document.body.style.fontSize = iBreite/1143*14+"pt";
}
Now you can determine diverent font-sizes (for nested HTML-elements in
relative values (%), which are related to the bodies font size.
div {font-size:150%;}
or
span {font-size:1.5em;}
are leading to a font size, of 1.5 times that of the body.
However you should use % to avoid problems with MSIE.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com