Solved

Add Text Size Options

Posted on 2013-10-29
2
272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
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 learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

734 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