父div上的css3缩放变换,但在某些关联的div中保持不变的大小 [英] css3 scale transform on parent div but keeping constant size in some of the associated divs

查看:491
本文介绍了父div上的css3缩放变换,但在某些关联的div中保持不变的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用css3缩放转换来缩放包含其他div的div.

I'm using css3 scale transform to scale a div that contains other divs inside.

我遇到的问题是,我需要保持某些内部div不变,基本上就好像它们没有缩放一样,其大小也不应更改,但是我确实需要缩放父div以及其他所有内容.

The problem I have is that some of the inner divs I need to keep as they were, basically as if they were not scaled, their size should not change, however I do need to scale the parent div with everything else inside.

如何反转某些div的缩放比例?
我正在尝试应用反比例缩放.
如果整个div的值设置为1.5,我正在尝试查找现在应缩放其他div值的值,以直观地将其还原为以前的样子.

How can you reverse the scaling in some of the divs?
I am trying to apply an inverse scaling.
If the overall div had applied a value of 1.5 , I'm trying to find what value I should now scale the other divs to revert them visually to how they looked before.

推荐答案

如果父div的缩放比例为1.5,则需要将子级的缩放比例为1/1.5 = 0.(6),以保持其大小常数.

If the parent div has been scaled by a factor of 1.5, then you need to scale the children by a factor of 1/1.5 = 0.(6) to keep their size constant.

通常,为了取消子元素的缩放变换,该缩放变换已应用于父元素且缩放因子为a,您需要在子元素本身上应用另一个因子1/a的缩放变换

In general, in order to cancel for a child element a scale transform that has been applied on the parent and has a scale factor of a, you need to apply another scale transform of factor 1/a on the child itself.

您要么需要:

  • 在执行其他任何操作之前,先手动计算比例因子,然后按原样使用它(如上例所示)
  • 使用预处理程序为您处理此问题( SASS示例 )
  • 使用JavaScript计算子级和子级所需的比例因子 在孩子上设置刻度transform
  • compute manually the scale factor before you do anything else and then use it as it is in your code (example linked above)
  • use a preprocessor to handle this for you (SASS example)
  • use JavaScript to compute the scale factor needed for the child and to set the scale transform on the child

这篇关于父div上的css3缩放变换,但在某些关联的div中保持不变的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆