button鼠标悬停动画背景

108 阅读1分钟

55.png

鼠标悬停,从左下角向右上角倾斜修改背景,去除transform: skewX(45deg);就是横着移动了
   <div class="tabs-button"> ALL </div>
css
.tabs-button {
  padding: 10px 20px;
  border: 1px solid #aaa;
  border-radius: 20px;
  margin: 25px;
  position: relative;
  overflow: hidden;
  font-weight: 600;
}
.tabs-button:hover {
  color: #fff;
  cursor: pointer;
}
.tabs-button::before {
  content: "";
  width: 0%;
  height: 100%;
  position: absolute;
  left: -30px;
  top: 0;
  background-color: #000;
  transform: skewX(45deg);
  z-index: -1;
  transition: all 0.5s;
}
.tabs-button:hover::before {
  width: 180%;
}