リンクボタン – 004

プレビュー

コードの紹介

html

<a href="#" class="cLinkButton">1st code</a>

CSS

.cLinkButton {
  text-decoration: none;
  border: 2px solid #000;
  color: #000;
  display: inline-block;
  padding: 8px 16px;

  position: relative;
  overflow: hidden;
  transition: all 0.3s ease-in;
}

.cLinkButton::before,
.cLinkButton::after {
  content: "";
  position: absolute;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  background: #000;
  z-index: -1;
  transition: all 0.3s ease-in;
}

.cLinkButton::before {
  left: 0;
  bottom: 0;
  transform: translate(-100%, 100%);
  clip-path: polygon(0% 0%, 100% 100%, 0% 100%);
}
.cLinkButton::after {
  top: 0;
  right: 0;
  transform: translate(100%, -100%);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}
.cLinkButton:hover {
  color: #fff;
}
.cLinkButton:hover::before,
.cLinkButton:hover::after {
  transform: translate(0%, 0%);
}