jquery - CSS 变换比例属性

标签 jquery css

我有一个大问题。我尝试调整页面上所有字体的大小。下面这段代码在 EDGE/CHROME 中工作正常,但在 FF 中不行:/我不知道该代码有什么问题...

$('#zoom_in').click(function() {
    $('body').css({
        '-moz-transform': 'scale(1.5, 1.5)', /* Moz-browsers */
        'zoom': 1.5, /* Other non-webkit browsers */
        'zoom': '150%' /* Webkit browsers */
    });
});

$('#zoom_reset').click(function() {
    $('body').css({
       '-moz-transform': 'scale(1.0, 1.0)', /* Moz-browsers */
        'zoom': 1.0, /* Other non-webkit browsers */
        'zoom': '100%' /* Webkit browsers */
    });
});

提前致谢!

最佳答案

$('#zoom_in').click(function() {
    $('body').css({
      'font-size' : '150%',
        'zoom': 1.5, /* Other non-webkit browsers */
        'zoom': '150%' /* Webkit browsers */
    });
});

$('#zoom_reset').click(function() {
    $('body').css({
       'font-size' : '100%',
        'zoom': 1.0, /* Other non-webkit browsers */
        'zoom': '100%' /* Webkit browsers */
    });
});
body{
  margin:0;
  padding:0;
  text-align:center;
  transition: all 1s ease;
  -webkit-transition: all 1s ease;
  -moz-transition: all 1s ease;
  -ms-transition: all 1s ease;
  font-size:100%;
}

button{
padding:0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<button id="zoom_in">Zoom In</button>
<button id="zoom_reset">Zoom Reset</button>

<p>
  Some Text
</p>

它在我的 Mozilla 浏览器中运行良好。 请检查此代码。 希望这会有所帮助。

关于jquery - CSS 变换比例属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44201065/

相关文章:

css - 对 Raphael 从外部样式表创建的 VML 元素进行样式化

javascript - 如何在 HTML 中的图像上显示动态值?

javascript - jQuery 不捕获某些按键组合(例如,ZXW)

jquery - 侧边栏最小高度 100% - 滚动时在下方创建间隙

jquery - 如何在 TypeScript 中扩展 JQuery 函数

css - 将关键帧动画合二为一

html - 我如何只编辑 Magento 主页的 css?

css - 如何水平对齐导航栏中的三个元素?

jquery - 防止文本环绕输入

javascript - 在图片库中使用 jquery 自动水平滚动?