我在下面有2个代码段。 在第一个,我有漂亮的条纹,他们调整自己的窗口大小,并始终居中(我尝试一些动画,但我不会像片段2中的动画那样得到它)
但我需要一个动画,这个动画显示在第二个片段中,条纹应该来自下方并且上升,我想在最终结果中保留它。
所以我需要与第一个和第二个片段融合。
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
#position: fixed;
}
.mask {
height: 100%;
overflow: hidden;
position: relative;
}
.container {
height: 100%;
margin: 0 -100vh;
#position: absolute;
}
.stripe {
float: left;
height: 100%;
width: 2%;
margin: 0 1%;
bottom: 0%;
max-height: 0%;
#position: absolute;
background-color: black;
transform: skew(-20deg);
#transform-origin: bottom bottom;
#transform-origin: left bottom;
animation: ani 1s linear 1 forwards;
}
.stripe:nth-child(1) {
animation-delay: 0.0s;
}
.stripe:nth-child(2) {
animation-delay: 0.2s;
}
.stripe:nth-child(3) {
animation-delay: 0.4s;
}
.stripe:nth-child(4) {
animation-delay: 0.6s;
}
.stripe:nth-child(5) {
animation-delay: 0.8s;
}
.stripe:nth-child(6) {
animation-delay: 1s;
}
.stripe:nth-child(7) {
animation-delay: 1.2s;
}
.stripe:nth-child(8) {
animation-delay: 1.4s;
}
.stripe:nth-child(9) {
animation-delay: 1.6s;
}
.stripe:nth-child(10) {
animation-delay: 1.8s;
}
.stripe:nth-child(11) {
animation-delay: 2s;
}
.stripe:nth-child(12) {
animation-delay: 2.2s;
}
.stripe:nth-child(13) {
animation-delay: 2.4s;
}
.stripe:nth-child(14) {
animation-delay: 2.6s;
}
.stripe:nth-child(15) {
animation-delay: 2.8s;
}
.stripe:nth-child(16) {
animation-delay: 3s;
}
.stripe:nth-child(17) {
animation-delay: 3.2s;
}
.stripe:nth-child(18) {
animation-delay: 3.4s;
}
.stripe:nth-child(19) {
animation-delay: 3.6s;
}
.stripe:nth-child(20) {
animation-delay: 3.8s;
}
.stripe:nth-child(21) {
animation-delay: 4s;
}
.stripe:nth-child(22) {
animation-delay: 4.2s;
}
.stripe:nth-child(23) {
animation-delay: 4.4s;
}
.stripe:nth-child(24) {
animation-delay: 4.6s;
}
.stripe:nth-child(25) {
animation-delay: 4.8s;
}
@keyframes ani {
0% {
max-height: 0%;
}
100% {
max-height: 100%;
}
}

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="mask">
<div class="container">
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
</div>
</div>
</body>
</html>
&#13;
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
position: fixed;
}
.stripe {
height: 100%;
width: 2%;
bottom: 0%;
max-height: 0%;
background-color: black;
position: fixed;
animation: ani 1s linear 1 forwards;
transform: skew(-10deg);
transform-origin: left bottom;
}
.stripe:nth-child(1) {
margin-left: 0%;
animation-delay: 0.0s;
}
.stripe:nth-child(2) {
margin-left: 4%;
animation-delay: 0.2s;
}
.stripe:nth-child(3) {
margin-left: 8%;
animation-delay: 0.4s;
}
.stripe:nth-child(4) {
margin-left: 12%;
animation-delay: 0.6s;
}
.stripe:nth-child(5) {
margin-left: 16%;
animation-delay: 0.8s;
}
.stripe:nth-child(6) {
margin-left: 20%;
animation-delay: 1s;
}
.stripe:nth-child(7) {
margin-left: 24%;
animation-delay: 1.2s;
}
.stripe:nth-child(8) {
margin-left: 28%;
animation-delay: 1.4s;
}
.stripe:nth-child(9) {
margin-left: 32%;
animation-delay: 1.6s;
}
.stripe:nth-child(10) {
margin-left: 36%;
animation-delay: 1.8s;
}
.stripe:nth-child(11) {
margin-left: 40%;
animation-delay: 2s;
}
.stripe:nth-child(12) {
margin-left: 44%;
animation-delay: 2.2s;
}
.stripe:nth-child(13) {
margin-left: 48%;
animation-delay: 2.4s;
}
.stripe:nth-child(14) {
margin-left: 52%;
animation-delay: 2.6s;
}
.stripe:nth-child(15) {
margin-left: 56%;
animation-delay: 2.8s;
}
.stripe:nth-child(16) {
margin-left: 60%;
animation-delay: 3s;
}
.stripe:nth-child(17) {
margin-left: 64%;
animation-delay: 3.2s;
}
.stripe:nth-child(18) {
margin-left: 68%;
animation-delay: 3.4s;
}
.stripe:nth-child(19) {
margin-left: 72%;
animation-delay: 3.6s;
}
.stripe:nth-child(20) {
margin-left: 76%;
animation-delay: 3.8s;
}
.stripe:nth-child(21) {
margin-left: 80%;
animation-delay: 4s;
}
.stripe:nth-child(22) {
margin-left: 84%;
animation-delay: 4.2s;
}
.stripe:nth-child(23) {
margin-left: 88%;
animation-delay: 4.4s;
}
.stripe:nth-child(24) {
margin-left: 92%;
animation-delay: 4.6s;
}
.stripe:nth-child(25) {
margin-left: 96%;
animation-delay: 4.8s;
}
@keyframes ani {
0% {
max-height: 0%;
}
100% {
max-height: 100%;
}
}
&#13;
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="mask">
<div class="container">
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
</div>
</div>
</body>
</html>
&#13;
感谢您的帮助!
答案 0 :(得分:1)
我改变了你的布局。
但主要区别在于从渐变的背景中获取动画效果并移动此渐变。以这种方式处理条纹位置要容易得多:
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.mask {
height: 100%;
overflow: hidden;
position: relative;
}
.container {
height: 100%;
margin-right: -100vh;
}
.stripe {
display: inline-block;
height: 100%;
width: 2%;
margin: 0 1%;
bottom: 0%;
transform: skew(-20deg);
transform-origin: top;
background-image: linear-gradient(to top, black 50%, transparent 50%);
background-size: 100% 200%;
animation: ani 1s forwards;
}
.stripe:nth-child(1) {
animation-delay: 0.0s;
}
.stripe:nth-child(2) {
animation-delay: 0.2s;
}
.stripe:nth-child(3) {
animation-delay: 0.4s;
}
.stripe:nth-child(4) {
animation-delay: 0.6s;
}
.stripe:nth-child(5) {
animation-delay: 0.8s;
}
.stripe:nth-child(6) {
animation-delay: 1s;
}
.stripe:nth-child(7) {
animation-delay: 1.2s;
}
.stripe:nth-child(8) {
animation-delay: 1.4s;
}
.stripe:nth-child(9) {
animation-delay: 1.6s;
}
.stripe:nth-child(10) {
animation-delay: 1.8s;
}
.stripe:nth-child(11) {
animation-delay: 2s;
}
.stripe:nth-child(12) {
animation-delay: 2.2s;
}
.stripe:nth-child(13) {
animation-delay: 2.4s;
}
.stripe:nth-child(14) {
animation-delay: 2.6s;
}
.stripe:nth-child(15) {
animation-delay: 2.8s;
}
.stripe:nth-child(16) {
animation-delay: 3s;
}
.stripe:nth-child(17) {
animation-delay: 3.2s;
}
.stripe:nth-child(18) {
animation-delay: 3.4s;
}
.stripe:nth-child(19) {
animation-delay: 3.6s;
}
.stripe:nth-child(20) {
animation-delay: 3.8s;
}
.stripe:nth-child(21) {
animation-delay: 4s;
}
.stripe:nth-child(22) {
animation-delay: 4.2s;
}
.stripe:nth-child(23) {
animation-delay: 4.4s;
}
.stripe:nth-child(24) {
animation-delay: 4.6s;
}
.stripe:nth-child(25) {
animation-delay: 4.8s;
}
@keyframes ani {
0% {
background-position: 100% 0%;
}
100% {
background-position: 100% 100%;
}
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="mask">
<div class="container">
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
<div class="stripe"></div>
</div>
</div>
</body>
</html>