![](/img/trans.png)
[英]Is there anyway to change font-size of all text with a specific font-size?
[英]Change font-size of all text including buttons using LocalStorage
在使用 LocalStorage 按下按钮后,我正在尝试更改 web 上所有文本的字体大小,包括按钮。 它只会更改<small>
、 <strong>
等标签中元素的字体大小(HTML 格式化文本标签),但不会更改标题标签中的元素,如<h1>
或<button>
。
我的代码:
mybutton.onclick = () => {
localStorage.setItem("fontsize", "300%");
location = location.href;
};
window.onload = function () {
var fonts = localStorage.getItem("fontsize");
body.style.fontSize = fonts;
不要在本地存储中使用字体大小,而是存储 class 名称并添加 class 到 javascript。
对于css,你可以这样做: *
选择器选择所有元素。 我在本地尝试过这个并且它有效,而且!important
是它覆盖任何其他 styles 所必需的。
.fontSize * {
font-size: 30px !important;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.