css - 如何在悬停时移动多个 svg 矩形?

标签 css animation svg transition

Basically i trying to make all the three part of the flag transition once the user hover at once not individually which what I've managed to do so far. i tried using 'g' as selector but it didn't work

<style type="text/css">

.st0{fill:#ED9E4F;}
.st1{fill:#F1F7E7;}
.st2{fill:#83C553;}

.aller .all:hover {
transition: 2s;
height: 25%;
}

</style>


<g> 
<rect id="XMLID_12_" x="153.6" class="st0 all" width="7.2" 
height="12.5"/>
<rect id="XMLID_13_" x="146.4" class="st1 all" width="7.2" 
height="12.5"/>
<rect id="XMLID_10_" x="139.2" class="st2 all" width="7.2" 
height="12.5"/>

</g>

</svg>

All the three part (rects) to slice downward at the same time no matter which one the user hover on run the code and you'll be able to get what im trying to say

最佳答案

我会把旗帜放在一个组中,悬停时我会转换比例。我希望这就是您要问的。

.st0 {
  fill: #ed9e4f;
}
.st1 {
  fill: #f1f7e7;
}
.st2 {
  fill: #83c553;
}

#flag {
  transform: scaleY(1);
  transition: transform 2s;
}
#flag:hover {
  transform: scaleY(0.25);
}
<svg viewBox="135 0 30 30">
<g id="flag"> 
<rect id="XMLID_12_" x="153.6" class="st0 all" width="7.2" 
height="12.5"/>
<rect id="XMLID_13_" x="146.4" class="st1 all" width="7.2" 
height="12.5"/>
<rect id="XMLID_10_" x="139.2" class="st2 all" width="7.2" 
height="12.5"/>
</g>

</svg>

关于css - 如何在悬停时移动多个 svg 矩形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55881108/

相关文章:

html - 删除空白处的链接下划线

css - 使用纯 CSS 在菜单下滑动箭头

javascript - D3.js 中止转换并防止结束事件

html - 确保页脚始终位于底部的最佳方法是什么

html - 将 div 内容 float 到 div 的底部。将所有内容粘贴到周围 div 的底部

javascript - 我的列表的下一个和上一个按钮不起作用

ios - 翻转过渡 UINavigationController 推送在动画完成之前不会调用 viewDidLoad

android - 淡入淡出 Java 中的 Android 动画

html - 为什么这两个元素之间会有差距?

html - 打印预览中不显示 CSS 剪辑路径 : why?