Solved

Add Text Size Options

Posted on 2013-10-29
2
264 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Link a VBS to an HTA 6 36
AdminLTE with wordpress 15 54
CSS: How do I override in-line styling 11 15
tiny glitch in my main slider 3 23
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

770 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