CSS - 增加页面字体大小 [英] CSS - Increase Page Font Size

查看:123
本文介绍了CSS - 增加页面字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

允许用户更改网页中的字体大小

Hello ,

我有一些网页。我想用户点击一个图像,并使页面上所有内容的字体大小增加。这可能吗?如果是,如何?

I have some webpages. I would like the user to click an image and have the font-sizes of all of the content on the page increase. Is this possible? If so, how?

我知道浏览器里面有选项。基本上,我想在页面本身做一个方法。

I know that the browsers have options inside of them. Basically, I want a way to do that in the page itself.

谢谢。

推荐答案

有三件事要实现:

指定整体字体标签中的< body> 例如:

Specify the overall font-size in the <body> tag. For example:

body { font-size: 100%; }

不要使用像素在文档中的任何其他位置指定字体大小。

Don't use pixels to specify font-size anywhere else in the document.

p.somePara { font-size: 120%; }
p.anotherPara { font-size: 1.4em; }

为此图片附加事件处理函数,以相应地调整字体大小。使用jQuery,例如:

Attach an event handler to this image, to adjust the font size accordingly. Using jQuery, for example:

$("#largerTextImage").click(function() {
  $("body").css("fontSize", "120%");
});

完成。

这篇关于CSS - 增加页面字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆