效果展示
CSS 知识点
页面整体布局
<div class="scroll" style="--t: 20s">
<div>
<span>HTML</span>
<span>CSS</span>
<span>JavaScript</span>
<span>React</span>
<span>Vue</span>
<span>Figma</span>
<span>PhotoShop</span>
<span>Angular</span>
</div>
<div>
<span>HTML</span>
<span>CSS</span>
<span>JavaScript</span>
<span>React</span>
<span>Vue</span>
<span>Figma</span>
<span>PhotoShop</span>
<span>Angular</span>
</div>
</div>
核心样式
编写基础样式
.scroll {
position: relative;
display: flex;
width: 700px;
overflow: hidden;
-webkit-mask-image: linear-gradient(
90deg,
transparent,
#fff 20%,
#fff 80%,
transparent
);
}
.scroll div {
white-space: nowrap;
}
.scroll div span {
display: inline-flex;
margin: 10px;
background: #333;
color: #fff;
padding: 5px 10px;
border-radius: 5px;
transition: 0.5s;
letter-spacing: 0.2em;
}
.scroll div span:hover {
background: #4caf50;
cursor: pointer;
}
编写动画样式
.scroll div {
white-space: nowrap;
}
@keyframes animate {
0% {
transform: translateX(100%);
}
100% {
transform: translateX(-100%);
}
}
完整代码下载
完整代码下载