gpt4 book ai didi

animation - SVG 矩形动画方向从下到上

转载 作者:行者123 更新时间:2023-12-05 05:10:45 25 4
gpt4 key购买 nike

我有以下 SVG 动画:

演示:https://codepen.io/anon/pen/xNJYGe

HTML:

<div class='batteryIcon'>
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 668.3 1108.2">
<rect class="power" x="100" y="150" width="470" height="880">
<animate attributeName="height" values="0 ; 880" dur="2.5s" />
</rect>
<polygon class="st0" points="444.9,80.7 444.9,15.8 231.2,15.8 231.2,80.7 40.3,80.7 40.3,1080.8 629.3,1080.8 629.3,80.7 "/>
</svg>
</div>

CSS:

.batteryIcon {
svg {
width: 50px;
display: block;
.st0 {
fill: none;
stroke: #adadad;
stroke-width: 20;
stroke-miterlimit: 5;
}
.power {
fill: #06B67A;
}
}
}

我的问题是动画从 _top 到 bottom 而不是 bottom to top。我尝试通过 CSS 和内联属性转换我的矩形,添加rotatedirection属性以及keyPoints。到目前为止没有任何效果。

最佳答案

您可以使用polygon 并为points 属性设置动画,而不是使用rect 和设置height 的动画.

.batteryIcon svg {
width: 50px;
display: block;
}
.batteryIcon svg .st0 {
fill: none;
stroke: #adadad;
stroke-width: 20;
stroke-miterlimit: 5;
}
.batteryIcon svg .power {
fill: #06B67A;
}
<div class='batteryIcon'>
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 668.3 1108.2">
<!--<rect class="power" x="100" y="150" width="470" height="880">
<animate attributeName="height" values="0 ; 880" dur="2.5s" />
</rect>-->

<polygon points="100,1030 570,1030 570,150 100,150">
<animate attributeName="points" values="100,1030 570,1030 570,1030 100,1030 ; 100,1030 570,1030 570,150 100,150" dur="2.5s" />
</polygon>
<polygon class="st0" points="444.9,80.7 444.9,15.8 231.2,15.8 231.2,80.7 40.3,80.7 40.3,1080.8 629.3,1080.8 629.3,80.7 "/>
</svg>
</div>

关于animation - SVG 矩形动画方向从下到上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56342956/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com