微信输入法这种进度条效果的按钮怎么用 CSS 实现
简单粗暴的方法就是两个文字叠加,一个文字放在进度条里面,然后进度条滚动过去之后就显示出来。
粗糙的代码大概就是这样:
<div>
<strong>正在安装...</strong>
<span><em>正在安装...</em></span>
</div>
div {
position: relative;
display: flex;
align-items: center;
justify-content: center;
margin: 0;
width: 200px;
height: 30px;
overflow: hidden;
border-radius: 8px;
background-color: #ceeee4;
}
span {
position: absolute;
top: 0;
left: 0;
bottom: 0;
width: 50%;
overflow: hidden;
background-color: #25cb93;
animation: loading 4s 0.5s infinite ease-in-out;
}
em {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 0;
left: 0;
width: 200px;
height: 30px;
font-style: normal;
font-weight: normal;
font-size: 16px;
color: #fff;
}
strong {
position: relative;
font-size: 16px;
color: #25cb93;
}
@keyframes loading {
0% {
width: 1%;
}
100% {
width: 100%;
}
}
3 回答5.1k 阅读✓ 已解决
5 回答1.9k 阅读
2 回答1.9k 阅读✓ 已解决
1 回答2.9k 阅读✓ 已解决
3 回答2.4k 阅读
4 回答2.2k 阅读
2 回答952 阅读✓ 已解决
linear-gradient
+background-position
+background-clip
兼容性可能不太好
Codepen