CSS进度条带斑马纹动画(有效果图)

效果图

.wxml

复制代码
<view class="tb">
  <view class="tb-line" style="transform:translateX({{w+'%'}})" />
</view>
<button bind:tap="updateLine">增加进度</button>

.js

复制代码
Page({
  data: {
    w:0,
  },
  updateLine(){
    this.setData({
      w:this.data.w >= 100 ? 20 : this.data.w + 20
    })
  },
})

.wxss

复制代码
.tb {
  width: 80%;
  margin: 100rpx 10%;
  height: 40rpx;
  border-radius: 50rpx;
  overflow: hidden;
  border: 1px solid #ccc;
  position: relative;
}
.tb-line{
  width: 100%;
  height: 100%;
  position: absolute;
  left: -100%;
  background: #46A758;
  transition: transform 0.5s;
  border-radius: 50rpx;
}
.tb-line::after{
  content:" ";
  position: absolute;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(-45deg,rgba(255,255,255,0.2) 25%,transparent 25%, transparent 50%,
  rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.2) 75%,transparent 75%, transparent);
  background-size: 60rpx 60rpx;
  animation: lineSize 0.5s infinite linear;
}
@keyframes lineSize {
  from{ background-position: 0 0; }
  to{ background-position:60rpx 0; }
}

遇到问题可以看我主页加我Q,很少看博客,对你有帮助别忘记点赞收藏。

相关推荐
德莱厄斯1 小时前
CSS 实现九宫格缩放(9-slice scaling 不变形拉伸)
前端·css·html
3Katrina1 小时前
为什么现代前端拒绝原生编程?组件化与框架的降维打击
前端·javascript·css
蓝婷儿2 小时前
第二章支线五 ·CSS炼金续章:变量与暗黑主题术
前端·css
sunbyte2 小时前
50天50个小项目 (Vue3 + Tailwindcss V4) ✨ | Dad Jokes(冷笑话卡片)
前端·javascript·css·vue.js·vue
gurenchang2 小时前
动态设置微信小程序页面标题(navigationBarTitleText属性)
微信小程序·小程序
Emma歌小白3 小时前
ReferenceError: wx is not defined
微信小程序
百锦再3 小时前
Microsoft前后端不分离编程新风向:cshtml
javascript·css·microsoft·html·web·web2.0·cshtml
站在风口的猪11083 小时前
《前端面试题:CSS有哪些单位!》
前端·css·html·css3·html5
八戒社5 小时前
如何使用插件和子主题添加WordPress自定义CSS(附:常见错误)
前端·css·tensorflow·wordpress
Hilaku5 小时前
为什么我不再相信 Tailwind?三个月重构项目教会我的事
前端·css·前端框架