jquery - 我怎样才能使我网站上的字体更大并且更易于某些用户阅读?

标签 jquery html css layout

我有一些用户提示我的 Web 应用程序上的字体太小而无法阅读。他们对尝试在浏览器上调整字体设置不满意,因为当他们使字体变大时,应用程序的尺寸和布局也会发生变化。有没有现成的工具可以让最终用户选择小号/中号/大号字体,并在不影响页面布局的情况下将网站的 .css 更改为更大的字体?

最佳答案

这是我在我的一些网站上使用的代码。相应地应用您的 HTML:

HTML:

<span>Font Size: </span>
<a href="#" onclick="decreaseFontSize();">
    <img src="/images/minus.png" alt="Decrease Font Size" />
</a>

<a href="#" onclick="increaseFontSize();">
    <img src="/images/plus.png" alt="Increase Font Size" />
</a>

Javascript:

var min=8;
var max=18;
function increaseFontSize() {
 p = document.getElementById("[the id of container w/font you want to size]");
 if(p.style.fontSize) {
 var s = parseInt(p.style.fontSize.replace("px",""));
 } else {
  var s = 12;
 }
 if(s!=max) {
  s += 1;
 }
 p.style.fontSize = s+"px"
}
function decreaseFontSize() {
 p = document.getElementById("[the id of container w/font you want to size]");
      if(p.style.fontSize) {
         var s = parseInt(p.style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p.style.fontSize = s+"px" 
}

关于jquery - 我怎样才能使我网站上的字体更大并且更易于某些用户阅读?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1792371/

相关文章:

html - 如何通过 Google Visualization API 将表格中的数字居中?

javascript - jquery 选择的选择验证消息在表单提交之前不会消失

javascript - 当未选择下拉菜单时,使用 jquery 获取默认值

javascript - 检测 IE8 中的 mouseout 事件

javascript - 带有图像描述的模态图像

javascript - 无法将 JS 文件添加到我的 HTML 中

javascript - 裁剪图像并使用 php 上传

javascript - 如何在 var() 中设置动态属性名称

jquery - 根据用户代理删除 jQuery 脚本

html - 如何将所有内容置于页面中心?