css线条

2022-06-20 08:19:44 浏览数 (1)

<div class = "myDiv" ></div>

代码语言:javascript复制
<style scoped>
.myDiv {
  margin-top: 10px;
  position: relative;
  width: 150px;
  height: 150px;
  margin: auto;
  color: #69ca62;
  box-shadow: inset 0 0 0 1px rgba(105, 202, 98, 0.5);
  margin-bottom:10px;
}
.myDiv::before,
.myDiv::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

.myDiv::before,
.myDiv::after {
  content: "";
  z-index: -1;
  margin: -5px;
  box-shadow: inset 0 0 0 2px;
  animation: clipMe 8s linear infinite;
}

.myDiv::before {
  animation-delay: -4s;
}

.myDiv:hover::after,
.myDiv:hover::before {
  /* background-color: rgba(255, 0, 0, 0.3); */
}

@keyframes clipMe {
  0%,
  100% {
    clip: rect(0px, 160px, 2px, 0px);
  }

  25% {
    clip: rect(0px, 2px, 160px, 0px);
  }

  50% {
    clip: rect(158px, 160px, 160px, 0px);
  }

  75% {
    clip: rect(0px, 160px, 160px, 158px);
  }
}
</style>

0 人点赞