gpt4 book ai didi

html - 无法让 CSS 动画在 Shopify 中工作

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

我无法在我的 Shopify page 中设置动画.如您所见,它是静态的,没有按应有的方式移动。我已经将 SASS 反编译为 CSS,我在检查元素工具中没有错误。我使用的是 Codepen 中的确切代码,我在 theme.scss.liquid 文件夹中有 CSS。所以我很困惑为什么它不起作用。感谢任何帮助。

https://codepen.io/marvindanig/pen/avLRJz

html

<div class="toy-train">
<div class="engine">
<div class="window">
<div class="engine-main">
<div class="smokes">
<span></span>
</div>
</div>
</div>
<div class="engine-body">
<div class="wheels">
<div class="big-wheel"></div>
<div class="normal-wheel"></div>
</div>
</div>
</div>
<div class="locomotive">
<div class="trash"></div>
<div class="wheels">
<div class="normal-wheel"></div>
<div class="normal-wheel"></div>
</div>
</div>
<div class="tracks">
<span></span>
<span></span>
</div>
</div>

CSS

#about-us{

body {
background: linear-gradient(90deg, #1A2980 10%, #26D0CE 90%);
height: 100vh;
width: 100vw;
display: flex;
align-items: center;
justify-content: center;
}

.toy-train {
position: relative;
width: 11vw;
}

.engine {
float: right;
position: relative;
}

.window {
height: 2.8vw;
width: 3vw;
background-color: #194488;
position: relative;
border: .3vw solid #000;
}

.window:before,
.window:after {
content: "";
position: absolute;
left: 50%;
border: .3vw solid #000;
}

.window:before {
height: .7vw;
background-color: #F82510;
width: 4.5vw;
margin-top: -1.3vw;
margin-left: -2.6vw;
border-radius: .8vw;
}

.window:after {
margin-left: -.8vw;
margin-top: .3vw;
border-radius: 50%;
height: 1.1vw;
width: 1.1vw;
background-color: #fff;
}

.engine-main {
height: 1vw;
width: 3.5vw;
border: .3vw solid #000;
background-color: #3D9A01;
position: absolute;
border-radius: 0 .8vw .8vw 0;
right: -4.1vw;
bottom: -.3vw;
}

.engine-main:before {
content: "";
height: 1vw;
width: .8vw;
background-color: #000;
position: absolute;
top: -1.1vw;
left: .4vw;
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
border-radius: 50% 50% 50% 50% / 90% 90% 40% 40%;
}

.engine-main:after {
content: "";
height: 1.2vw;
width: .8vw;
position: absolute;
display: block;
right: .5vw;
top: -1.8vw;
border-radius: 50% 50% 50% 50% / 90% 90% 40% 40%;
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
z-index: -1;
background-color: #194488;
border: .3vw solid #000;
}

.engine-body {
height: 1.7vw;
width: 7.5vw;
position: absolute;
left: -.2vw;
top: 3.0vw;
background-color: #F69F00;
border: .3vw solid #000;
border-radius: .5vw;
}

.engine-body .big-wheel {
top: .3vw;
left: .2vw;
}

.engine-body .normal-wheel {
left: 4.5vw;
top: .5vw;
}

.engine-body:before {
content: "";
position: absolute;
height: .5vw;
width: .5vw;
left: -1.1vw;
bottom: .2vw;
z-index: -1;
background-color: #fff;
border-radius: 50%;
border: .3vw solid #000;
}

.wheels > div {
position: absolute;
background-color: #F82510;
border-radius: 50%;
border: .3vw solid #000;
-webkit-animation: wheel-rotate 1s linear infinite;
animation: wheel-rotate 1s linear infinite;
}

.wheels > div:before {
content: "";
position: absolute;
width: 100%;
border-bottom: .1vw solid #000;
top: 50%;
margin-top: -.1vw;
}

.wheels > div:after {
content: "";
height: .8vw;
width: .8vw;
position: absolute;
background-color: #000;
border-radius: 50%;
left: 50%;
top: 50%;
margin-left: -.4vw;
margin-top: -.4vw;
}

.wheels .big-wheel {
width: 2.2vw;
height: 2.2vw;
-webkit-animation-delay: -0.3s;
animation-delay: -0.3s;
}

.wheels .normal-wheel {
height: 2.0vw;
width: 2.0vw;
-webkit-animation-delay: -0.6s;
animation-delay: -0.6s;
}

.locomotive {
height: 3.5vw;
width: 6.0vw;
border: .3vw solid #000;
background-color: #F69F00;
border-radius: .5vw;
position: relative;
float: left;
margin-top: 1.3vw;
}

.locomotive:before {
content: "";
width: 100%;
background: linear-gradient(to right, #000000 0%, #000000 8%, #f69f00 8%, #f69f00 15%, #000000 15%, #000000 28%, #000000 34%, #f69f00 34%, #f69f00 65%, #000000 65%, #000000 65%, #000000 100%);
height: .3vw;
position: absolute;
top: .6vw;
left: 0;
}

.locomotive:after {
content: "";
width: 100%;
background: linear-gradient(to right, #000000 0%, #000000 24%, #f69f00 24%, #f69f00 65%, #f69f00 65%, #000000 65%, #000000 85%, #f69f00 85%, #f69f00 90%, #000000 90%, #000000 100%);
height: .3vw;
position: absolute;
top: 1.4vw;
left: 0;
}

.locomotive .wheels > div {
top: 2.2vw;
-webkit-animation-delay: -0.6s;
animation-delay: -0.6s;
}

.locomotive .wheels > div:first-child {
-webkit-animation-delay: -0.9s;
animation-delay: -0.9s;
}

.locomotive .normal-wheel:first-of-type {
left: .2vw;
}

.locomotive .normal-wheel:last-of-type {
right: .2vw;
}

.locomotive .trash {
height: 3.5vw;
width: 5.0vw;
position: absolute;
top: -1.8vw;
border: .3vw solid #000;
background-color: #3D9A01;
border-radius: 50%;
left: .2vw;
z-index: -1;
}

.tracks {
position: relative;
width: 20vw;
bottom: -1vw;
overflow: hidden;
height: .3vw;
}

.tracks span {
display: inline;
height: .3vw;
width: 20vw;
position: absolute;
left: 20vw;
background: linear-gradient(to right, black 0%, black 30%, transparent 30%, transparent 39%, black 39%, black 61%, black 65%, transparent 65%, transparent 70%, black 71%, black 100%);
-webkit-animation: track 2s linear infinite;
animation: track 2s linear infinite;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}

.tracks span:nth-child(2) {
-webkit-animation-delay: -1s;
animation-delay: -1s;
}

.smokes:before,
.smokes:after,
.smokes span:before {
display: block;
content: "";
height: .8vw;
width: .8vw;
background-color: #fff;
border-radius: 50%;
position: absolute;
right: .8vw;
top: 1.5vw;
z-index: -1;
}

.smokes:before {
-webkit-animation: smoke 1s linear infinite;
animation: smoke 1s linear infinite;
}

.smokes span:before {
-webkit-animation: smoke 1s linear infinite;
animation: smoke 1s linear infinite;
-webkit-animation-delay: -0.6s;
animation-delay: -0.6s;
}

.smokes:after {
-webkit-animation: smoke 1s linear infinite;
animation: smoke 1s linear infinite;
-webkit-animation-delay: -0.3s;
animation-delay: -0.3s;
}

@-webkit-keyframes smoke {
100% {
top: -5vw;
opacity: 0.5;
}
}

@keyframes smoke {
100% {
top: -5vw;
opacity: 0.5;
}
}

@-webkit-keyframes wheel-rotate {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}

@keyframes wheel-rotate {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}

@-webkit-keyframes track {
100% {
left: -20vw;
}
}

@keyframes track {
100% {
left: -20vw;
}
}

}

最佳答案

只需关闭第一个选择器或将其删除:

#about-us{#about-us{}

#about-us{}

body {
background: linear-gradient(90deg, #1A2980 10%, #26D0CE 90%);
height: 100vh;
width: 100vw;
display: flex;
align-items: center;
justify-content: center;
}

.toy-train {
position: relative;
width: 11vw;
}

.engine {
float: right;
position: relative;
}

.window {
height: 2.8vw;
width: 3vw;
background-color: #194488;
position: relative;
border: .3vw solid #000;
}

.window:before,
.window:after {
content: "";
position: absolute;
left: 50%;
border: .3vw solid #000;
}

.window:before {
height: .7vw;
background-color: #F82510;
width: 4.5vw;
margin-top: -1.3vw;
margin-left: -2.6vw;
border-radius: .8vw;
}

.window:after {
margin-left: -.8vw;
margin-top: .3vw;
border-radius: 50%;
height: 1.1vw;
width: 1.1vw;
background-color: #fff;
}

.engine-main {
height: 1vw;
width: 3.5vw;
border: .3vw solid #000;
background-color: #3D9A01;
position: absolute;
border-radius: 0 .8vw .8vw 0;
right: -4.1vw;
bottom: -.3vw;
}

.engine-main:before {
content: "";
height: 1vw;
width: .8vw;
background-color: #000;
position: absolute;
top: -1.1vw;
left: .4vw;
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
border-radius: 50% 50% 50% 50% / 90% 90% 40% 40%;
}

.engine-main:after {
content: "";
height: 1.2vw;
width: .8vw;
position: absolute;
display: block;
right: .5vw;
top: -1.8vw;
border-radius: 50% 50% 50% 50% / 90% 90% 40% 40%;
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
z-index: -1;
background-color: #194488;
border: .3vw solid #000;
}

.engine-body {
height: 1.7vw;
width: 7.5vw;
position: absolute;
left: -.2vw;
top: 3.0vw;
background-color: #F69F00;
border: .3vw solid #000;
border-radius: .5vw;
}

.engine-body .big-wheel {
top: .3vw;
left: .2vw;
}

.engine-body .normal-wheel {
left: 4.5vw;
top: .5vw;
}

.engine-body:before {
content: "";
position: absolute;
height: .5vw;
width: .5vw;
left: -1.1vw;
bottom: .2vw;
z-index: -1;
background-color: #fff;
border-radius: 50%;
border: .3vw solid #000;
}

.wheels > div {
position: absolute;
background-color: #F82510;
border-radius: 50%;
border: .3vw solid #000;
-webkit-animation: wheel-rotate 1s linear infinite;
animation: wheel-rotate 1s linear infinite;
}

.wheels > div:before {
content: "";
position: absolute;
width: 100%;
border-bottom: .1vw solid #000;
top: 50%;
margin-top: -.1vw;
}

.wheels > div:after {
content: "";
height: .8vw;
width: .8vw;
position: absolute;
background-color: #000;
border-radius: 50%;
left: 50%;
top: 50%;
margin-left: -.4vw;
margin-top: -.4vw;
}

.wheels .big-wheel {
width: 2.2vw;
height: 2.2vw;
-webkit-animation-delay: -0.3s;
animation-delay: -0.3s;
}

.wheels .normal-wheel {
height: 2.0vw;
width: 2.0vw;
-webkit-animation-delay: -0.6s;
animation-delay: -0.6s;
}

.locomotive {
height: 3.5vw;
width: 6.0vw;
border: .3vw solid #000;
background-color: #F69F00;
border-radius: .5vw;
position: relative;
float: left;
margin-top: 1.3vw;
}

.locomotive:before {
content: "";
width: 100%;
background: linear-gradient(to right, #000000 0%, #000000 8%, #f69f00 8%, #f69f00 15%, #000000 15%, #000000 28%, #000000 34%, #f69f00 34%, #f69f00 65%, #000000 65%, #000000 65%, #000000 100%);
height: .3vw;
position: absolute;
top: .6vw;
left: 0;
}

.locomotive:after {
content: "";
width: 100%;
background: linear-gradient(to right, #000000 0%, #000000 24%, #f69f00 24%, #f69f00 65%, #f69f00 65%, #000000 65%, #000000 85%, #f69f00 85%, #f69f00 90%, #000000 90%, #000000 100%);
height: .3vw;
position: absolute;
top: 1.4vw;
left: 0;
}

.locomotive .wheels > div {
top: 2.2vw;
-webkit-animation-delay: -0.6s;
animation-delay: -0.6s;
}

.locomotive .wheels > div:first-child {
-webkit-animation-delay: -0.9s;
animation-delay: -0.9s;
}

.locomotive .normal-wheel:first-of-type {
left: .2vw;
}

.locomotive .normal-wheel:last-of-type {
right: .2vw;
}

.locomotive .trash {
height: 3.5vw;
width: 5.0vw;
position: absolute;
top: -1.8vw;
border: .3vw solid #000;
background-color: #3D9A01;
border-radius: 50%;
left: .2vw;
z-index: -1;
}

.tracks {
position: relative;
width: 20vw;
bottom: -1vw;
overflow: hidden;
height: .3vw;
}

.tracks span {
display: inline;
height: .3vw;
width: 20vw;
position: absolute;
left: 20vw;
background: linear-gradient(to right, black 0%, black 30%, transparent 30%, transparent 39%, black 39%, black 61%, black 65%, transparent 65%, transparent 70%, black 71%, black 100%);
-webkit-animation: track 2s linear infinite;
animation: track 2s linear infinite;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}

.tracks span:nth-child(2) {
-webkit-animation-delay: -1s;
animation-delay: -1s;
}

.smokes:before,
.smokes:after,
.smokes span:before {
display: block;
content: "";
height: .8vw;
width: .8vw;
background-color: #fff;
border-radius: 50%;
position: absolute;
right: .8vw;
top: 1.5vw;
z-index: -1;
}

.smokes:before {
-webkit-animation: smoke 1s linear infinite;
animation: smoke 1s linear infinite;
}

.smokes span:before {
-webkit-animation: smoke 1s linear infinite;
animation: smoke 1s linear infinite;
-webkit-animation-delay: -0.6s;
animation-delay: -0.6s;
}

.smokes:after {
-webkit-animation: smoke 1s linear infinite;
animation: smoke 1s linear infinite;
-webkit-animation-delay: -0.3s;
animation-delay: -0.3s;
}

@-webkit-keyframes smoke {
100% {
top: -5vw;
opacity: 0.5;
}
}

@keyframes smoke {
100% {
top: -5vw;
opacity: 0.5;
}
}

@-webkit-keyframes wheel-rotate {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}

@keyframes wheel-rotate {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}

@-webkit-keyframes track {
100% {
left: -20vw;
}
}

@keyframes track {
100% {
left: -20vw;
}
}

}
<div class="toy-train">
<div class="engine">
<div class="window">
<div class="engine-main">
<div class="smokes">
<span></span>
</div>
</div>
</div>
<div class="engine-body">
<div class="wheels">
<div class="big-wheel"></div>
<div class="normal-wheel"></div>
</div>
</div>
</div>
<div class="locomotive">
<div class="trash"></div>
<div class="wheels">
<div class="normal-wheel"></div>
<div class="normal-wheel"></div>
</div>
</div>
<div class="tracks">
<span></span>
<span></span>
</div>
</div>

关于html - 无法让 CSS 动画在 Shopify 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53156882/

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