简体   繁体   English

所有浏览器均使用javascript放大和缩小元素

[英]ZoomIn and zoomOut a element using javascript for all browsers

I want to implement a zoom in, zoom out function for an element in my web page it should be worked on all browsers. 我想为网页中的元素实现放大,缩小功能,该功能应在所有浏览器上均可使用。 I have done some code but it's not working on firefox because I have given CSS zoom for scaling. 我已经完成了一些代码,但是在firefox上不起作用,因为我已经给出了CSS缩放比例。 Here my code 这是我的代码

var currentZoom = 1.0;
var zoomElement = $('.ci-journey-interactions-canvas__row');
$('#btn_ZoomIn').click(
    function () {
    $("body").addClass("zoom-active");
    if ($(zoomElement).css('zoom') >= 1.75) {
        alert('Maximum zoomin')
    } else {
        $(zoomElement).animate({
            'zoom': currentZoom += .25,
        }, {
            'complete': zoomInCallback()
        }, 'fast');
    }
});

How could i make this all browser compatible? 我该如何使所有浏览器兼容?

you can manipulate the CSS "transform: scale(1.5)" in javascript, and use a container div with overflow:hidden so that the element doesn't take extra space. 您可以在javascript中操纵CSS“ transform:scale(1.5)”,并使用带有div:hidden的容器div,以使元素不会占用额外的空间。 you will also need to handle left and top positions on inside element to keep it centered. 您还需要处理内部元素的左侧和顶部位置,以使其居中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM