CSS转换:规模不会改变DOM大小?

时间:2015-09-29 03:19:42

标签: css css-transforms

变换后Container的DOM宽度与变换前相同?

为什么?

var theScale = aNumber;
var containerWidth = theContainer.width();
alert(containerWidth);

// and the other prefixes, as well
theContainer.css("-webkit-transform", "scale(" + theScale + ")");

containerWidth = theContainer.width();
alert(containerWidth);   // the same value ???

1 个答案:

答案 0 :(得分:15)

变换不会影响元素的布局 - 或者更确切地说是框模型。它们纯粹是化妆品。来自spec

  

注意:转换会影响画布上的可视布局,但不会影响CSS布局本身。这也意味着转换不会影响getClientRects()中指定的Element Interface Extensions getBoundingClientRect()[CSSOM-VIEW]的结果。