gpt4 book ai didi

html - 将 CSS 嵌入到 SVG 中以创建脉动圆圈

转载 作者:太空宇宙 更新时间:2023-11-04 00:59:27 25 4
gpt4 key购买 nike

有没有办法将这个 Codepen CSS 嵌入到 SVG 中以创建一个独立的 SVG 文件(即图标)?基本上将整个 Codepen 代码转换为 1 个 .svg 文件

This is the link to the Codepen

<div class="pulse-container">
<div class="pulse-box">
<svg class="pulse-svg" width="50px" height="50px" viewBox="0 0 50 50" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<circle class="circle first-circle" fill="#FF6347" cx="25" cy="25" r="25"></circle>
<circle class="circle second-circle" fill="#FF6347" cx="25" cy="25" r="25"></circle>
<circle class="circle third-circle" fill="#FF6347" cx="25" cy="25" r="25"></circle>
<circle class="circle" fill="#FF6347" cx="25" cy="25" r="25"> </circle>
</svg>
</div>
</div>

最佳答案

根据doc , 您可以使用 <style> <svg> 中的元素.

另一方面,请注意您的 Codepen 在 SCSS 而不是 CSS

这是我快速将您的代码转换为 CSS 的示例:

<div class="pulse-container">
<div class="pulse-box">
<svg class="pulse-svg" width="50px" height="50px" viewBox="0 0 50 50" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

<style>
/* <![CDATA[ */

.pulse-box {
float: left;
width: 50%;
height: 250px;
display: flex;
justify-content: center;
align-items: center;
}
/* pulse in SVG */
svg.pulse-svg {
overflow: visible;
}

svg.pulse-svg .first-circle {
fill: #f00;
transform: scale(0.5);
transform-origin: center center;
animation: pulse-me 3s linear infinite;
}
svg.pulse-svg .second-circle {
fill: #f00;
transform: scale(0.5);
transform-origin: center center;
animation: pulse-me 3s linear infinite;
animation-delay: 1s;
}
svg.pulse-svg .third-circle {
fill: #f00;
transform: scale(0.5);
transform-origin: center center;
animation: pulse-me 3s linear infinite;
animation-delay: 2s;
}


/* pulse in CSS */
.pulse-css {
width: 30px;
height: 30px;
border-radius: 15px;
background: tomato;
position: relative;
}
.pulse-css:before,
.pulse-css:after {
content: "";
width: 30px;
height: 30px;
border-radius: 15px;
background-color: tomato;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
transform: scale(0.5);
transform-origin: center center;
animation: pulse-me 3s linear infinite;
}
.pulse-css:after {
animation-delay: 2s;
}


@keyframes pulse-me {
0% {
transform: scale(0.5);
opacity: 0;
}
50% {
opacity: 0.1;
}
70% {
opacity: 0.09;
}
100% {
transform: scale(5);
opacity: 0;
}
}

/* ]]> */
</style>

<circle class="circle first-circle" fill="#FF6347" cx="25" cy="25" r="25"></circle>
<circle class="circle second-circle" fill="#FF6347" cx="25" cy="25" r="25"></circle>
<circle class="circle third-circle" fill="#FF6347" cx="25" cy="25" r="25"></circle>
<circle class="circle" fill="#FF6347" cx="25" cy="25" r="25"></circle>
</svg>
</div>
</div>

关于html - 将 CSS 嵌入到 SVG 中以创建脉动圆圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53807454/

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