社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Jquery

为什么在使用jquery的firefox中放大和缩小功能不能正常工作?

elysiancode • 4 年前 • 817 次点击  

请检查屏幕截图: https://nimb.ws/ZSxTbW

请检查屏幕截图: https://nimb.ws/SeX0sw

这是我的代码:

$('#In').on('click', function () {
    if (navigator.userAgent.indexOf('Firefox') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Firefox') + 8)) >= 3.6) {//Firefox  
        var step = 0.02;
        currFFZoom += step;
        $('body').css('MozTransform', 'scale(' + currFFZoom + ')');
        save_zoom_level(currFFZoom);
    } else {
        var step = 2;
        currIEZoom += step;
        $('body').css('zoom', ' ' + currIEZoom + '%');
        save_zoom_level(currIEZoom);
    }
});

$('#Out').on('click', function () {
    if (navigator.userAgent.indexOf('Firefox') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Firefox') + 8)) >= 3.6) {//Firefox  
        var step = 0.02;
        currFFZoom -= step;
        $('body').css('MozTransform', 'scale(' + currFFZoom + ')');
        save_zoom_level(currFFZoom);

    } else {
        var step = 2;
        currIEZoom -= step;
        $('body').css('zoom', ' ' + currIEZoom + '%');
        save_zoom_level(currIEZoom);
    }
});
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/56472
 
817 次点击  
文章 [ 1 ]  |  最新文章 4 年前
Sandip Nirmal
Reply   •   1 楼
Sandip Nirmal    4 年前

我认为你不需要做这么多检查。财产 transform: scale(1.5)

你可以做如下的事情。

function zoomIn() {
  var element = document.getElementById("content");
  element.classList.add("zoomIn");
}

function zoomOut() {
 var element = document.getElementById("content");
  element.classList.remove('zoomIn').add("zoomOut");
}
.content {
  width: 200px;
  height: 200px;
  background: #eab600;
  margin-top: 50px;
}

.zoomOut {
  transform: scale(0.9);
}

.zoomIn {
  transform: scale(1.5);
}
  <button onclick="zoomIn()">Zoom In</button>
  <button onclick='zoomOut()'>Zoom Out</button>
  
  <div id='content' class='content'></div>