Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28614
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Change font size in multiple classes |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <l8-dnaGgOJ9fWXrInZ2dnUU7-VOdnZ2d@westnet.com.au> <font-size-20150903062100@ram.dialup.fu-berlin.de> <XnsA50A6E8843ADDeejj99@194.109.6.166> <cvOdnTKEy9vIvnXInZ2dnUU7-amdnZ2d@westnet.com.au> |
| Date | 2015-09-03 16:24 +0200 |
| Message-ID | <XnsA50AA6E49E45Feejj99@194.109.6.166> (permalink) |
Andrew Poulos <ap_prog@hotmail.com> wrote on 03 Sep 2015 in
comp.lang.javascript:
> On 3/09/2015 6:51 PM, Evertjan. wrote:
>> ram@zedat.fu-berlin.de (Stefan Ram) wrote on 03 Sep 2015 in
>> comp.lang.javascript:
>>
>>> Andrew Poulos <ap_prog@hotmail.com> writes:
>>>> Is one way "better" than the other or is there another way to do this?
>>>
>>> Maybe you can use a JavaScript element right behind the
>>> style element to convert all the px values into em values
>>> (only once, when the page is loaded). When no contents has
>>> been displayed yet, this should be faster than when it is
>>> done later.
>>
>> Works fine, start with:
>>
>> body {font-size:62.5%;} // <http://pxtoem.com/>
>>
>> and
>>
>> temp = document.getElementsByTagName('*');
>> for (el in temp)
>> if (temp[el].style && temp[el].style.fontSize)
>> temp[el].style.fontSize =
>> temp[el].style.fontSize.replace(/(\d)px/,'.$1em');
>>
>
> I'm having a little trouble getting it to work (but thanks for the way
> forward).
What seems to be the trouble?
I only tested on Chrome, but should be working on all modern browsers.
Do not try to dynamicly change the 62.5% until the above is working,
and changing that same 62.5% does as expected other than by debugging with
F12 and the up and down keys.
> So far I've changed
> temp = document.getElementsByTagName('*');
> to
> temp = document.body.getElementsByTagName('*');
Why?
Do you have tags having a style
[and if so then also having a fontsize]
outside the body?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Change font size in multiple classes Andrew Poulos <ap_prog@hotmail.com> - 2015-09-03 13:55 +1000
Re: Change font size in multiple classes "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-03 10:09 +0200
Re: Change font size in multiple classes "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-03 10:51 +0200
Re: Change font size in multiple classes Andrew Poulos <ap_prog@hotmail.com> - 2015-09-03 20:39 +1000
Re: Change font size in multiple classes Jake Jarvis <pig_in_shoes@yahoo.com> - 2015-09-03 16:20 +0200
Re: Change font size in multiple classes "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-03 16:27 +0200
Re: Change font size in multiple classes Jake Jarvis <pig_in_shoes@yahoo.com> - 2015-09-03 16:30 +0200
Re: Change font size in multiple classes "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-03 16:39 +0200
Re: Change font size in multiple classes Andrew Poulos <ap_prog@hotmail.com> - 2015-09-04 15:49 +1000
Re: Change font size in multiple classes "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-04 09:37 +0200
Re: Change font size in multiple classes Andrew Poulos <ap_prog@hotmail.com> - 2015-09-04 18:11 +1000
Re: Change font size in multiple classes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-09-07 03:33 +0200
Re: Change font size in multiple classes "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-03 16:24 +0200
Re: Change font size in multiple classes Dr J R Stockton <reply1500@merlyn.demon.co.uk.invalid> - 2015-09-05 20:49 +0100
Re: Change font size in multiple classes Andrew Poulos <ap_prog@hotmail.com> - 2015-09-06 19:30 +1000
Re: Change font size in multiple classes Dr J R Stockton <reply1500@merlyn.demon.co.uk.invalid> - 2015-09-07 20:27 +0100
Re: Change font size in multiple classes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-09-06 14:07 +0200
Re: Change font size in multiple classes Andrew Poulos <ap_prog@hotmail.com> - 2015-09-07 09:53 +1000
Re: Change font size in multiple classes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-09-07 20:35 +0200
Re: Change font size in multiple classes Andrew Poulos <ap_prog@hotmail.com> - 2015-09-08 14:18 +1000
Re: Change font size in multiple classes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-09-09 04:51 +0200
csiph-web