更改整个页面内容的文本字体大小 [英] change text-font size of whole page content

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

问题描述

在javascript / css中有一种方法,我可以改变所有的标签,标题,段落等的文字大小在一个单一的点击,没有显式获取元素的id,然后改变它的字体大小。



我现在做的是,我通过javascript获取元素的id和显式更改其字体大小。要清楚了解我在做什么,请检查此链接或检查以下代码

 < script type =text / javascript> 
function changemysize(myvalue){
var div = document.getElementById(mymain);
div.style.fontSize = myvalue +px;
}
< / script>

HTML代码

 选择文本大小:
< font size =2>< a href =javascript:void(0); onclick =changemysize(16);> A< / a>< / font>
< font size =4>< a href =javascript:void(0); onclick =changemysize(20);> A< / a>< / font>
< font size =5>< a href =javascript:void(0); onclick =changemysize(25);> A< / a>< / font>
< div id =mymain>
只有此文本受到影响
< / div>


解决方案

body 标记,然后继续使用JavaScript更改其字体大小。这将更改您的网页中的每个元素的字体大小!这很简单!


is there a way in javascript/css that i can change text size of all the labels, headings, paragraphs etc on a single click and without explicitly getting element's id and then changing its font size.

what i am doing right now is that i get element's id through javascript and change its font size explicitly. To get a clear picture of what i am doing check this link or check the following code

<script type="text/javascript">
function changemysize(myvalue) {
    var div = document.getElementById("mymain");
    div.style.fontSize = myvalue + "px";   
}
</script>

HTML code

Choose a text size:
<font size="2"><a href="javascript:void(0);" onclick="changemysize(16);">A</a></font>
<font size="4"><a href="javascript:void(0);" onclick="changemysize(20);">A</a></font>
<font size="5"><a href="javascript:void(0);" onclick="changemysize(25);">A</a></font>
<div id="mymain">
Only this text gets affected
</div>

解决方案

Add an id to the body tag and then go ahead and change it's font size with JavaScript. This will change the font size for every element inside your webpage! It is as simple as that!

这篇关于更改整个页面内容的文本字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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