zoom css/javascript

后端 未结 3 396
有刺的猬
有刺的猬 2020-12-01 09:44

I would like to know how zoom property can be controlled through javascript, like div.style.top , how to specify for zoom ?

相关标签:
3条回答
  • 2020-12-01 09:57

    It is a property of style, but it's not supported by all browsers. It's a non-standard Microsoft extension of CSS that Internet Explorer implements. It is accessed like this:

    div.style.zoom
    
    0 讨论(0)
  • 2020-12-01 10:04

    The Firefox & Chrome (Webkit) equivalents to the IE-specific zoom property are, respectively, -moz-transform and -webkit-transform.

    A sample code would be:

    .zoomed-element {
        zoom: 1.5;
        -moz-transform: scale(1.5);
        -webkit-transform: scale(1.5);
    }
    

    You'd have to be a bit more careful with Javascript (test for existence first), but here's how you'd manipulate them:

    el.style.zoom = 1.5;
    el.style.MozTransform = 'scale(1.5)';
    el.style.WebkitTransform = 'scale(1.5)';
    
    0 讨论(0)
  • 2020-12-01 10:18

    You might want to try a lightweight jQuery plugin called Zoomoz. It uses CSS3 transform properties (translate, rotate, scale). Check out the "Zooming the jQuery way section. Hope it helps.

    $(document).ready(function() {
        $("#element").zoomTarget();
    });
    
    0 讨论(0)
提交回复
热议问题