我正在添加一个辅助功能工具,用户可以增加页面上所有文本的字体大小,并且可以根据需要返回到默认字体大小。我制作了第二个 CSS 文件,其中包含用于增加文本的 css 规则。但是,当我单击为文本变大/文本变小而制作的图标时,它不起作用。任何人都可以理解为什么吗?感谢您的帮助。
首页HTML代码:
<div id="font-size-buttons">
<a href="#" onclick="changeCSS('notaccessible.css', 2);"><img src="http://www.me14ch.leedsnewmedia.net/slate/images2/fontmin.png" width="25" height"25" alt="Switch to original text size and colours"></a>
<a href="#" onclick="changeCSS('stylesheet.css', 2);"><img src="http://www.me14ch.leedsnewmedia.net/slate/images2/fontmax.png" width="30" height="30" alt="Switch to larger text and improved colour contrast"></a>
</div>
一些默认的CSS样式表代码:
.body {
height: 100%;
overflow: auto;
padding-bottom: 25px;
font-size: 0.75em;
}
/* accessibility */
#font-size-buttons {
float: right;
clear: both;
margin-right: 5px;
}
以及替代样式表中的 CSS:
body {
font-size: 1.5em;
}
以及我的 index.html 页面顶部的链接样式表代码:
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<link href="http://me14ch.leedsnewmedia.net/slate/notaccessible.css" rel=alternate stylesheet" type="text/css" title="access"/>
最佳答案
那是因为 changeCSS
没有定义。
在 onclick="....">
中,您执行一段 Javascript,在您的例子中是一个名为 changeCSS
的函数,带有变量 'notaccessible。 css'
和 2
.
但是在您的代码中没有任何地方有一个名为 changeCSS
的函数。因此,您要么必须编写该函数,要么更改您的 html。
[编辑]
关于html - 为什么我的放大文本大小的辅助工具不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30185953/