非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

The non-standard zoom CSS property can be used to control the magnification level of an element. transform: scale() should be used instead of this property, if possible. However, unlike CSS Transforms, zoom affects the layout size of the element.

/* Keyword values */
zoom: normal;
zoom: reset;
/* <percentage> values */
zoom: 50%;
zoom: 200%;
/* <number> values */
zoom: 1.1;
zoom: 0.7;
/* Global values */
zoom: inherit;
zoom: initial;
zoom: unset;
					

句法

normal

Render this element at its normal size.

reset
Do not (de)magnify this element if the user applies non-pinch-based zooming (e.g. by pressing Ctrl - - or Ctrl + + keyboard shortcuts) to the document. Only supported by WebKit (and possibly Blink).
<percentage>
Zoom factor. 100% 相当于 normal . Values larger than 100% zoom in. Values smaller than 100% zoom out.
<number>
Zoom factor. Equivalent to the corresponding percentage ( 1.0 = 100% = normal ). Values larger than 1.0 zoom in. Values smaller than 1.0 zoom out.

形式定义

初始值 normal
适用于 所有元素
继承 no
计算值 如指定
动画类型 an integer

形式句法

normal | reset | <number> | <percentage>
					

范例

First example

HTML

<p class="small">Small</p>
<p class="normal">Normal</p>
<p class="big">Big</p>
					

CSS

p.small {
  zoom: 75%;
}
p.normal {
  zoom: normal;
}
p.big {
  zoom: 2.5;
}
p {
  display: inline-block;
}
p:hover {
  zoom: reset;
}
					

结果

Second example

HTML

<div id="a" class="circle"></div>
<div id="b" class="circle"></div>
<div id="c" class="circle"></div>
					

CSS

div.circle {
  width: 25px;
  height: 25px;
  border-radius: 100%;
  text-align: center;
  vertical-align: middle;
  display: inline-block;
  zoom: 1.5;
}
div#a {
  background-color: gold;
  zoom: normal;
}
div#b {
  background-color: green;
  zoom: 200%;
}
div#c {
  background-color: blue;
  zoom: 2.9;
}
					

结果

规范

Not part of any standard. This property originated in Internet Explorer. Apple has a description in the Safari CSS Reference . Rossen Atanassov of Microsoft has an unofficial draft specification proposal on GitHub .

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
zoom 非标 Chrome 完整支持 1 Edge 完整支持 12 Firefox 不支持 No 注意事项
不支持 No 注意事项
注意事项 bug 390936 .
IE 完整支持 5.5 Opera 完整支持 15 Safari 完整支持 3.1 WebView Android 完整支持 ≤37 Chrome Android 完整支持 18 Firefox Android 不支持 No 注意事项
不支持 No 注意事项
注意事项 bug 390936 .
Opera Android 完整支持 14 Safari iOS 完整支持 3 Samsung Internet Android 完整支持 1.0
reset value 非标 Chrome 不支持 1 — 59 Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera 不支持 15 — 46 Safari 完整支持 3.1 WebView Android 不支持 ≤37 — 59 Chrome Android 不支持 18 — 59 Firefox Android 不支持 No Opera Android 不支持 14 — 43 Safari iOS 完整支持 3 Samsung Internet Android 不支持 1.0 — 7.0

图例

完整支持

完整支持

不支持

不支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

见实现注意事项。

见实现注意事项。

另请参阅

元数据

  • 最后修改: