Skip to main content

One post tagged with "animation"

View All Tags

· One min read
Jeffrey

示例

scss 实现:将 id content_html 内子元素添加滑动进入动画

#content_html {
margin-top: 20px;
padding: 0 15px;

p,
li {
margin: 15px 0;
font-size: 16px;
line-height: 25px;
}

ul,
li {
list-style: inside;
}

h1,
h2,
h3,
h4,
h5,
h6 {
font-size: 19px;
font-weight: 700;
letter-spacing: -0.025rem;
line-height: 1.8rem;
margin: 20px 0;
outline: none;
}

h2 {
font-size: 18px;
}

h3 {
font-size: 17px;
}

h4,
h5,
h6 {
font-size: 16px;
}

@keyframes slide-enter {
0% {
opacity: 0;
transform: translateY(10px);
}

to {
opacity: 1;
transform: none;
}
}

* {
--stagger: 0;
--delay: 150ms;
--start: 0ms;
animation: slide-enter 1s both 1;
animation-delay: calc(var(--start) + var(--stagger) * var(--delay));
}

* {
counter-increment: enter-count;
--stagger: counter(enter-count);
}

.slide-enter-content > * {
--stagger: 0;
--delay: 150ms;
--start: 0ms;
animation: slide-enter 1s both 1;
animation-delay: calc(var(--start) + var(--stagger) * var(--delay));
}

@for $i from 1 through 30 {
*:nth-child(#{$i}) {
--stagger: #{$i};
}
}
}

参考-antfu