jquery实时控制网页字体,无限制放大缩小。你可以一直点击放大或缩小,字体一直会被放大或缩小,而不受限制,不过,似乎一直这么下去,也没什么意义,应该定义最大和最小的字体,仅供参考。
为解决一些网页特效运行后不能显示效果(例如:jQuery则需要刷新)问题,烈火特别新增网页版演示。
点击查看:网页特效
运行演示:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> <title>jquery实时控制网页字体放大缩小 - 烈火网</title> <style> * { margin:0; padding:0; } .msg {width:300px; margin:100px; } .msg_caption { width:100%; overflow:hidden; margin-bottom:1px;} .msg_caption span { display:block; float:left; margin:0 2px; padding:4px 10px; background:#898989; cursor:pointer;font-size:12px;color:white; } .msg textarea{ width:300px; height:80px;height:100px;border:1px solid #000;} </style> <script src="/uploads/common/js/jquery-1.4.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ $("span").click(function(){ var thisEle = $("#para").css("font-size"); var textFontSize = parseFloat(thisEle , 10); var unit = thisEle.slice(-2); //获取单位 var cName = $(this).attr("class"); if(cName == "bigger"){ textFontSize += 2; }else if(cName == "smaller"){ textFontSize -= 2; } $("#para").css("font-size", textFontSize + unit ); }); }); </script> </head> <body> <div class="msg"> <div class="msg_caption"> <span class="bigger" >放大</span> <span class="smaller" >缩小</span> </div> <div> <p id="para" > 烈火网(veryhuo.com)提供计算机知识、网站运营、软件应用、设计教程、编程开发与IT资讯等为主要宗旨,同时有源码下载、站长工具、在线手册、免费资源等内容,是国内快捷易懂、内容丰富的网上学习平台。 </p> </div> </div> </body> </html><div style="text-align:center;margin:30px 0 0 0;"><hr style="color:#999;height:1px;">如不能显示效果,请按Ctrl+F5刷新本页,更多网页代码:<a href='http://www.veryhuo.com/' target='_blank'>http://www.veryhuo.com/</a></div>提示:可修改后代码再运行!