如何定位由Lottie动画创建的SVG元素?
我试图针对我与CSS的Lottie动画创建的SVG元素,以给它一些Border-Radius。我对JavaScript和CSS的经验不足,我不知道该怎么做。
我已经尝试通过使用以下方式将SVG元素定位为Lottie-player-Element的孩子,因为
lottie-player svg {
border-radius: 9px;
}
我认为这是不起作用的,因为SVG在原始HTML代码中不存在,并且后来通过JavaScript添加。那是对的吗?
您有什么想法如何通过CSS赋予这个动画圆角?
这是一个可以播放的代号: https://codepen.io/kartenhouse/kartenhouse/pen/pen/pen/pen/jjjpmxem
非常感谢您的帮助!
I'm trying to target the svg-element that's created by my lottie-animation with CSS to give it some border-radius. Being rather unexperienced with JavaScript and CSS, I couldn't figure out how to do it.
I've already tried targeting the svg-element as a child of the lottie-player-element by using:
lottie-player svg {
border-radius: 9px;
}
I assume this doesn't work, because the svg isn't present in the original HTML code and only added later through JavaScript. Is that correct?
Do you have any ideas how to give this animation rounded corners, ideally through CSS?
Here's a codepen to play around with: https://codepen.io/Kartenhouse/pen/JjpmXem
Thanks a lot for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试创建父div,然后在那里进行所有CSS属性,而不是将其用于Lottie Player。
就像我所做的。 codepen for参考
父母
最终输出看起来像这样
注意:如果您需要Lottie控件,则需要编写自己的逻辑才能使玩家开始和停止动画。
Try creating a parent div and do all CSS properties there instead to lottie player.
Like what I have done. Codepen for reference
HTML : Parented the lottie player
CSS : Added CSS to parent div instead of HTML.
The final output looks like this
Note: If you need lottie controls then you need to write your own logic for player to start and stop animation.