[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Add Text Size Options

Posted on 2013-10-29
2
Medium Priority
?
276 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 1000 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 1000 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

649 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