svg+css实现不规则虚线框流动效果

方法一:
用来实现规则矩形

.box {
  width: 850px;
  height: 195px;
  color: #000;
  position: absolute;
  left: 809px;
  top: 373px;
  z-index: 2;
  background: linear-gradient(90deg, #a84d31 50%, transparent 0) repeat-x,
    linear-gradient(90deg, #a84d31 50%, transparent 0) repeat-x,
    linear-gradient(0deg, #a84d31 50%, transparent 0) repeat-y,
    linear-gradient(0deg, #a84d31 50%, transparent 0) repeat-y;
  background-size: 16px 3px, 16px 3px, 3px 16px, 3px 16px;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  animation: linearGradientMove 0.3s infinite linear;
}
// 虚线动画
@keyframes linearGradientMove {
 100% {
   background-position: 16px 0, -16px 100%, 0 -16px, 100% 16px;
}

方法二:
使用svg+css可以实现规则矩形和不规则形状的虚线框流动效果

 <div class="an-line-box">
   <svg height="100%" width="100%"> xmlns="http://www.w3.org/2000/svg">
       <polyline class="g-dashed-line" points="4 3 195 3 195 471 4 471 4 3" stroke="#ddd" fill="transparent" stroke-width="2.5" />
   </svg>
 </div>

css部分

.an-line-box {
  width: 670px;
  height: 550px;
  position: absolute;
  left: 5px;
  top: 286px;
  .g-dashed-line {
    stroke: #80eafd;
    stroke-dasharray: 8, 7;
    stroke-dashoffset: 0;
    animation: move 19s infinite linear;
  }
}
@keyframes move {
  0% {
      stroke-dashoffset: 0;
  }
  100% {
      stroke-dashoffset: -1000;
  }
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值