Solved

Add Text Size Options

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

746 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

12 Experts available now in Live!

Get 1:1 Help Now