<div class="layout">
  <!-- ここからボタンのHTML -->
  
  <!-- ボタンの背景を左上と右下でスライス -->
  <div class="button-01">
    <a href="#">ボタン</a>
  </div>
  
  <!-- ボタンの背景を左下と右上でスライス -->
  <div class="button-02">
    <a href="#">ボタン</a>
  </div>
  
  <!-- ここまでボタンのHTML -->
</div>
/* ここはレイアウトなのでボタンとは関係ない */
* {
  margin: 0;
}

.layout {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 50px;
  width: 100%;
  height: 100vh;
}

/* ここからボタンのCSS */
.button-01 {
	a {
		position: relative;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 240px;
		height: 50px;
		font-size: 16px;
		text-decoration: none;
		color: #5cc0ef;
		border: 1px solid #5cc0ef;
		overflow: hidden;
		transition: all 0.5s;

		&::before,
		&::after {
			content: "";
			position: absolute;
			z-index: -1;
			top: 0;
			right: 0;
			bottom: 0;
			left: 0;
			width: calc(100% + 2px);
			height: calc(100% + 2px);
			background-color: #5cc0ef;
			transition: all 0.3s;
		}

		&::before {
			transform: translate(-100%, -100%);
			clip-path: polygon(0 0, 0 100%, 100% 100%, 100% 99%, 1% 0);
		}

		&::after {
			transform: translate(100%, 100%);
			clip-path: polygon(0 0, 100% 0, 100% 100%, 99% 100%, 0 1%);
		}

		&:hover {
			color: #fff;

			&::before {
				transform: translate(0%, 0%);
			}

			&::after {
				transform: translate(0%, 0%);
			}
		}
	}
}

.button-02 {
	a {
		position: relative;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 240px;
		height: 50px;
		font-size: 16px;
		text-decoration: none;
		color: #5cc0ef;
		border: 1px solid #5cc0ef;
		overflow: hidden;
		transition: all 0.5s;

		&::before,
		&::after {
			content: "";
			position: absolute;
			z-index: -1;
			top: 0;
			right: 0;
			bottom: 0;
			left: 0;
			width: calc(100% + 2px);
			height: calc(100% + 2px);
			background-color: #5cc0ef;
			transition: all 0.3s;
		}

		&::before {
			transform: translate(-100%, 100%);
			clip-path: polygon(100% 0, 0 0, 0 100%, 1% 100%, 100% 1%);
		}

		&::after {
			transform: translate(100%, -100%);
			clip-path: polygon(100% 0, 99% 0, 0 99%, 0 100%, 100% 100%);
		}

		&:hover {
			color: #fff;

			&::before {
				transform: translate(0%, 0%);
			}

			&::after {
				transform: translate(0%, 0%);
			}
		}
	}
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.