gpt4 book ai didi

jquery-mobile - 是否可以在 jquery mobile 中更改整个应用程序的字体

转载 作者:行者123 更新时间:2023-12-02 04:59:19 26 4
gpt4 key购买 nike

在我的应用程序中有字段更改字体 实际上使用该用户可以更改整个应用程序的字体。如果我的项目中有 100 个字段(可能是不同的不同字体大小),这实际上可能吗每个页面)。用户如何更改字体大小。以便它可以反射(reflect)整个应用程序。当我目瞪口呆时,我发现有放大和缩小的功能。这不是一个好方法。?有什么办法可以改变整个应用程序的字体吗?

最佳答案

您可以动态创建样式并将其应用于 body 中的所有元素。

Demo

 $('#select_font').on('change', function () {
var style;
var font = $(this).val();
if ($('head').find('style.font').length === 0) {
style = $('<style class="font">.font { font-size: ' + font + ' !important; }</style>');
$('head').append(style);
$('body *').addClass('font');
} else {
$('body *').removeClass('font');
$('style.font').empty();
style = '.font { font-size: ' + font + ' !important; }';
$('style.font').append(style);
$('body *').addClass('font');
}
});

关于jquery-mobile - 是否可以在 jquery mobile 中更改整个应用程序的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17378048/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com