Solved

Add Text Size Options

Posted on 2013-10-29
2
261 Views
Last Modified: 2013-10-31
Is there an easy way to add an option to a website so someone can select which text size they want to view the site in?   I have seen samples of this where there is a small "A", medium "A" and large "A".  CLicking on any of these will automaticallly adjust the size of the site fonts.  I assume it is somehow related to a ccs file.  FYI,  I use dreamweaver.
0
Comment
Question by:nsitedesigns
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 250 total points
ID: 39610053
Using jQuery
http://jsfiddle.net/GaryC123/Y44K3/1/
<body>
    <img id="larger" alt="Increase">
    <img id="smaller" alt="Decrease">
</body>

Open in new window


$("#larger").click(function(){
var fontSize = parseInt($("body").css("font-size"));
    fontSize = fontSize + 1 + "px";
$("body").css({'font-size':fontSize});
})

$("#smaller").click(function(){
var fontSize = parseInt($("body").css("font-size"));
    fontSize = fontSize - 1 + "px";
$("body").css({'font-size':fontSize});
})

Open in new window

0
 
LVL 53

Assisted Solution

by:COBOLdinosaur
COBOLdinosaur earned 250 total points
ID: 39610156
Actually it is much simpler than that.  Set the font size in a css rule for the html tag.

html {font-size: 15px;}

then set all other font sizes relative it using rem units which the same as em but instead of referring to the local font they refer to the root font.

So if you set the body font-size using rem and everything else uses percentages, and change in the body rule will cascade.

so if: body {font-size;1em;}
then you can increase the size of everything cascading from it with an onclick event like:
onclick="document.body.style.fontSize='1.5em'; and increase the fonts by 50%.

rem is support in all modern browsers.

Cd&
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now