通过css 里面的font-size属性修改,比如:
position:relativeleft:0pxtop:0px
width:autoheight:82px
line-height:95pxvertical-align: middle
font-size:80px
display: inline-block
自己改一下 同事触发两个<p>标签就好<!DOCTYPE html>
<html>
<head>
<title>字体变大变小</title>
<meta charset="UTF-8" />
<style type="text/css">
#txt {
font-size: 15px
}
</style>
</head>
<body>
<p id="txt">字体变大变小 </p>
<input type="button" id="btn1" value="A+" />
<input type="button" id="btn2" value="A-" />
<script type="text/javascript">
window.onload=function(){
var oTxt=document.getElementById("txt")
var oBtn1=document.getElementById("btn1")
var oBtn2=document.getElementById("btn2")
var num=15
oBtn1.onclick=function(){
if (num==20) {
num=20
}else{
num=num+1
}
oTxt.style.fontSize=num+"px"
}
oBtn2.onclick=function(){
if (num==12) {
num=12
}else{
num=num-1
}
oTxt.style.fontSize=num+"px"
}
}
</script>
</body>
</html>