缩放 CSS/JavaScript

发布于 2024-08-17 08:04:02 字数 59 浏览 3 评论 0原文

我想知道如何通过javascript控制缩放属性, 像 div.style.top 一样,如何指定缩放?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我只土不豪 2024-08-24 08:04:02

火狐浏览器和Chrome (Webkit) 相当于 IE 特定的 zoom 属性,分别是 -moz-transform-webkit-transform

示例代码如下:

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

您必须对 Javascript 更加小心(首先测试是否存在),但操作它们的方法如下:

el.style.zoom = 1.5;
el.style.MozTransform = 'scale(1.5)';
el.style.WebkitTransform = 'scale(1.5)';

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)';
臻嫒无言 2024-08-24 08:04:02

它是 style 的一个属性,但并非所有浏览器都支持。它是 Internet Explorer 实现的 CSS 的非标准 Microsoft 扩展。它的访问方式如下:

div.style.zoom

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
錯遇了你 2024-08-24 08:04:02

您可能想尝试一个名为 Zoomoz 的轻量级 jQuery 插件。它使用 CSS3 变换属性(平移、旋转、缩放)。查看“缩放 jQuery 方式”部分。希望它有所帮助。

$(document).ready(function() {
    $("#element").zoomTarget();
});

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();
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文