gpt4 book ai didi

html - 了解如何在简单的 SVG 中创建蜡烛火焰

转载 作者:行者123 更新时间:2023-11-28 16:39:00 24 4
gpt4 key购买 nike

我只是在看一个简单的 SVG 蛋糕动画 HERE ,CSS 代码如下所示:

@import url(http://fonts.googleapis.com/css?family=Lato:300italic);

html,
body {
width: 100%;
height: 100%;
}

body {
background: #ee9ca7;
}

#cake {
display: block;
position: relative;
margin: -10em auto 0 auto;
}

*/* ============================================== Candle
*/
.velas {
background: #ffffff;
border-radius: 10px;
position: absolute;
top: 228px;
left: 50%;
margin-left: -2.4px;
margin-top: -8.33333333px;
width: 5px;
height: 35px;
transform: translateY(-300px);
backface-visibility: hidden;
animation: in 500ms 6s ease-out forwards;
}
.velas:after,
.velas:before {
background: rgba(255, 0, 0, 0.4);
content: "";
position: absolute;
width: 100%;
height: 2.22222222px;
}
.velas:after {
top: 25%;
left: 0;
}
.velas:before {
top: 45%;
left: 0;
}
/* ============================================== Fire
*/
.fuego {
border-radius: 100%;
position: absolute;
top: -20px;
left: 50%;
margin-left: -2.6px;
width: 6.66666667px;
height: 18px;
}
.fuego:nth-child(1) {
animation: fuego 2s 6.5s infinite;
}
.fuego:nth-child(2) {
animation: fuego 1.5s 6.5s infinite;
}
.fuego:nth-child(3) {
animation: fuego 1s 6.5s infinite;
}
.fuego:nth-child(4) {
animation: fuego 0.5s 6.5s infinite;
}
.fuego:nth-child(5) {
animation: fuego 0.2s 6.5s infinite;
}
/* ============================================== Animation Fire
*/
@keyframes fuego {
0%, 100% {
background: rgba(254, 248, 97, 0.5);
box-shadow: 0 0 40px 10px rgba(248, 233, 209, 0.2);
transform: translateY(0) scale(1);
}
50% {
background: rgba(255, 50, 0, 0.1);
box-shadow: 0 0 40px 20px rgba(248, 233, 209, 0.2);
transform: translateY(-20px) scale(0);
}
}
@keyframes in {
to {
transform: translateY(0);
}
}
.text {
color: #8b6a60;
font-family: 'Lato', sans-serif;
font-weight: 300;
font-style:italic;
text-align: center;
h1 {
font-size: 1.4em;
}
}

稍微检查一下代码后,我开始知道蜡烛火焰是由这组 HTML 元素引起的:

    <div class="velas">
<div class="fuego"></div>
<div class="fuego"></div>
<div class="fuego"></div>
<div class="fuego"></div>
<div class="fuego"></div>
</div>

此 HTML 具有以下 CSS 代码:

  background: #ffffff;
border-radius: 10px;
position: absolute;
top: 228px;
left: 50%;
margin-left: -2.4px;
margin-top: -8.33333333px;
width: 5px;
height: 35px;
transform: translateY(-300px);
backface-visibility: hidden;
animation: in 500ms 6s ease-out forwards;
}
.velas:after,
.velas:before {
background: rgba(255, 0, 0, 0.4);
content: "";
position: absolute;
width: 100%;
height: 2.22222222px;
}
.velas:after {
top: 25%;
left: 0;
}
.velas:before {
top: 45%;
left: 0;
}

/* ============================================== Fire
*/

.fuego {
border-radius: 100%;
position: absolute;
top: -20px;
left: 50%;
margin-left: -2.6px;
width: 6.66666667px;
height: 18px;
}
.fuego:nth-child(1) {
animation: fuego 2s 6.5s infinite;
}
.fuego:nth-child(2) {
animation: fuego 1.5s 6.5s infinite;
}
.fuego:nth-child(3) {
animation: fuego 1s 6.5s infinite;
}
.fuego:nth-child(4) {
animation: fuego 0.5s 6.5s infinite;
}
.fuego:nth-child(5) {
animation: fuego 0.2s 6.5s infinite;
}

/* ============================================== Animation Fire
*/

@keyframes fuego {
0%, 100% {
background: rgba(254, 248, 97, 0.5);
box-shadow: 0 0 40px 10px rgba(248, 233, 209, 0.2);
transform: translateY(0) scale(1);
}
50% {
background: rgba(255, 50, 0, 0.1);
box-shadow: 0 0 40px 20px rgba(248, 233, 209, 0.2);
transform: translateY(-20px) scale(0);
}
}

@keyframes in {
to {
transform: translateY(0);
}
}

现在我看不到实际上引起红色和黄色火焰的 CSS 代码,我相信白色阴影是由动画中给出的非常高的框阴影引起的,但不知何故我看不到蜡烛在哪里火焰被创造出来,有人能指导我蜡烛火焰是在哪里真正创造出来的吗?

最佳答案

颜色由 RGB 值设置。有黄色、红色和一些粉红色。

@keyframes fuego {
0%, 100% {
background: rgba(254, 248, 97, 0.5); /* yellow */
box-shadow: 0 0 40px 10px rgba(248, 233, 209, 0.2); /* pink */
transform: translateY(0) scale(1);
}
50% {
background: rgba(255, 50, 0, 0.1); /* red */
box-shadow: 0 0 40px 20px rgba(248, 233, 209, 0.2); /* pink again */
transform: translateY(-20px) scale(0);
}
}

更改颜色的时间设置在 .fuego:nth-child(1).fuego:nth-child(6)

关于html - 了解如何在简单的 SVG 中创建蜡烛火焰,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34022783/

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