简体   繁体   English

使用包装器按比例调整 div 的大小

[英]Proportionally resizing divs with a wrapper

Basically I have a bunch of elements inside a div, lets say <div class="wrapper"> .基本上我在一个 div 中有一堆元素,比如说<div class="wrapper"> I want to be able to scale this outer div and have the elements inside scale properly along with it.我希望能够缩放这个外部 div 并使里面的元素与它一起正确缩放。

For example, if this were a collection of SVGs all we would have to do is change the transform of the outer SVG.例如,如果这是一组 SVG,我们所要做的就是更改外部 SVG 的变换。 to get this result:得到这个结果:

Scaled SVG from blue bounding box从蓝色边界框缩放 SVG

I want to do this same effect with a div wrapper... Is that even possible?我想用 div 包装器做同样的效果......这可能吗? (The reason I want to do this is because I want to be able to use img tags etc, otherwise I would simply use the svgs). (我想这样做的原因是因为我希望能够使用 img 标签等,否则我只会使用 svgs)。 If it helps, the end goal is to allow the user to drag and drop elements to create their own interface, but it would help if it works on multiple screens.如果有帮助,最终目标是允许用户拖放元素来创建自己的界面,但如果它可以在多个屏幕上工作,则会有所帮助。

Credit to @samuellawrentz归功于@samuellawrentz

Use transform:scale(x, y) to scale any wrapper element使用transform:scale(x, y)缩放任何包装元素

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM