CSSのみ:ボタンサンプル(ホバーエフェクト付き)

今回はCSSで実装できるボタンのサンプルを紹介します。すべてホバーエフェクト付きです。

2022/8/26 : 2個追加しました。
2022/9/2 : 1個追加しました。
2022/9/21 : 2個追加しました。
2022/11/25 : 1個追加しました。
2022/12/2 : 1個追加しました。

1.下線が消える

デモ

HTML

<a href="#">READ MORE</a>

CSS

a{
	display: inline-block;
	font-size: 1.8rem;
	font-weight: 500;
	position: relative;
}
a::after{
	content: '';
	width: 100%;
	height: 1px;
	position: absolute;
	bottom: 1px;
	left: 0;
	background: #111;
	transition: all .3s;
	transform: scale(1, 1);
	transform-origin: right top;
}
a:hover::after{ transform: scale(0, 1); }

2.線が引かれる(マーカー風)

デモ

HTML

<a href="#">READ MORE</a>

CSS

a{
	display: inline-block;
	font-size: 1.8rem;
	font-weight: 500;
	position: relative;
}
a::after{
	content: '';
	width: 100%;
	height: 8px;
	background:#b7986c;
	position: absolute;
	bottom: 5px;
	left: 0;
	z-index: -1;
	transition: all .3s;
	transform: scale(0, 1);
	transform-origin: left top;
}
a:hover::after{ transform: scale(1, 1); }

3.矢印が動く

デモ

HTML

<a href="#">READ MORE</a>

CSS

a{
	width: 180px;
	display: block;
	position: relative;
	font-size: 1.8rem;
	font-weight: 500;
	color: #111;
}
a::before{
	content: '';
	width: 42px;
	height: 1px;
	position: absolute;
	background-color: #111;
	right: 0;
	bottom: 11px;
	transition: all .3s;
}
a::after{
	content: '';
	width: 12px;
	height: 1px;
	position: absolute;
	background: #111;
	bottom: 15px;
	right: 0;
	transform: rotate(40deg);
	transition: all .3s;
}
a:hover::before{ transform: translateX(10px); }
a:hover::after{ transform: translateX(10px) rotate(40deg); }

4.矢印がのびる

デモ

HTML

<a href="#">READ MORE</a>

CSS

a{
	width: 250px;
	display: block;
	position: relative;
	font-size: 1.8rem;
	font-weight: 500;
	color: #111;
}
a::before{
	content: '';
	width: 42px;
	height: 1px;
	position: absolute;
	background-color: #111;
	top: 50%;
	right: 75px;
	transition: all .3s;
}
a::after{
	content: '';
	width: 12px;
	height: 12px;
	border: 1px solid #111;
	border-left: 0;
	border-bottom: 0;
	position: absolute;
	top: 50%;
	right: 75px;
	transition: all .3s;
	transform: rotate(45deg);
	transform-origin: top right;
}
a:hover::before{
	content: '';
	width: 97px;
	right: 20px;
}
a:hover::after{
	content: '';
	right: 20px;
}

5.丸枠の色が変わる

デモ

HTML

<a href="#"><span>→</span></a>

CSS

a{
	width: 70px;
	height: 70px;
	position: relative;
	display: flex;
	justify-content: center;
	align-items: center;
	background: #111;
	border-radius: 50px;
	font-size: 3rem;
	transition: initial;
	overflow: hidden;
}
a span{
	color: #fff;
	z-index: 1000;
}
a:hover .btn02 span{
	color: #555;
	transition: 0.6s all;
}
a:before{
	content: '';
	width: 60px;
	height: 60px;
	margin: auto;
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	border-radius: 50%;
	background: #999898;
	transform: scale(0);
	transition: .6s all;
}
a:hover:before{ transform: scale(3); }

6.丸枠が拡大する

デモ

HTML

<a href="#"><span>→</span></a>

CSS

a{
	width: 40px;
	height: 40px;
	position: relative;
	display: flex;
	justify-content: center;
	align-items: center;
	background: #111;
	border-radius: 50px;
	font-size: 2rem;
	transition: initial;
}
a span{
	color: #fff;
	z-index: 1000;
}
a:hover .btn03 span{ transition: .4s all; }
a:before{
	content: '';
	width: 30px;
	height: 30px;
	margin: auto;
	position: absolute;
	top: 0;
	bottom: 0;
	right: 0;
	left: 0;
	border-radius: 50px;
	background: #111;
	transform: scale(0);
	transition: .4s all;
}
a:hover:before{ transform: scale(2); }

7.丸枠の色が変わる+拡大する

デモ

HTML

<a href="#"><span>→</span></a>

CSS

a{
	width: 60px;
	height: 60px;
	position: relative;
	display: flex;
	justify-content: center;
	align-items: center;
	background: #111;
	border-radius: 50px;
	font-size: 3rem;
	transition: .3s all;
}
a span{
	color: #fff;
	z-index: 1000;
}
a:hover .btn09 span{
	color: #555;
	transition: 1s all;
}
a:hover{
	background: #999898;
	transform: scale(1.2);
}

8.下から色が変わる

デモ

HTML

<a href="#">READ MORE</a>

CSS

a{
	width: 200px;
	height: 45px;
	display: flex;
	border: 2px solid #111;
	border-radius: 50px;
	font-weight: 500;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	position: relative;
	transition: all .3s;
}
a::after{
	content: '';
	width: 100%;
	height: 60px;
	display: block;
	position: absolute;
	top: 45px;
	left: 0;
	z-index: -1;
	background-color: #111;
	transition: all .3s;
}
a:hover{ color: #fff; }
a:hover::after{ top: 0; }

9.左から色が変わる+矢印が動く

デモ

HTML

<a href="#"><span class="text">READ MORE</span><span class="arrow">→</span></a>

CSS

a{
	width: 200px;
	padding: 10px;
	display: block;
	font-weight: 500;
	background: #111;
	position: relative;
	overflow: hidden;
}
a::before{
	content: '';
	width: 100%;
	height: 100%;
	position: absolute;
	top: 0;
	right: 200px;
	background: #999898;
	transition: all .3s;
}
a .text{
	position: relative;
	color: #fff;
}
a .arrow{
	position: absolute;
	right: 15px;
	color: #fff;
	transition: all .3s;
}
a:hover::before{ right: 0; }
a:hover .arrow{ transform: translateX(5px); }

10.テキストがずれて矢印が表示される(2022/8/26追記)

デモ

HTML

<a href="#"><span>READ MORE</span></a>

CSS

a{
	display: block;
	font-size: 1.8rem;
	font-weight: 500;
	position: relative;
	transition: all .3s;
}
a::before{
	content: '→';
	position: absolute;
	top: 0;
	left: 0;
	opacity: 0;
}
a:hover{
	color: #b7986c;
	padding-left: 2rem;
}
a:hover:before{ opacity: 1; }

11.テキストが入れ替わる(2022/8/26追記)

デモ

HTML

<a href="#"><span class="textEn">READ MORE</span><span class="textJa">詳しく見る</span></a>

CSS

a{
	width: 200px;
	height: 50px;
	display: block;
	color: #fff;
	font-weight: 500;
	line-height: 50px;
	background: #111;
	position: relative;
	overflow: hidden;
}
a span{
	width: 100%;
	height: 100%;
	position: absolute;
	left: 0;
	text-align: center;
	transition: all .5s;
}
a .textEn{ top: 0; }
a .textJa{ bottom: -100%; }
a:hover .textEn{ top: -100%; }
a:hover .textJa{ bottom: 0; }

12.枠のみ拡大する(2022/9/2追記)

デモ

HTML

<a href="#"><span>READ MORE</span></a>

CSS

a{
	width: 200px;
	height: 50px;
	display: inline-flex;
	position: relative;
	color: #fff;
	align-items: center;
	justify-content: center;
}
a::before{
	content: '';
	width: 100%;
	height: 100%;
	position: absolute;
	top: 0;
	left: 0;
	background: #111;
	border-radius: 50px;
	transition: all .3s;
}
a span{
	position: relative;
	font-weight: 500;
}
a:hover::before{ transform: scale(1.2); }

13.丸い飾りが出てくる(2022/9/21追記)

デモ

HTML

<a href="#">READ MORE</a>

CSS

a{
	display: inline-block;
	font-size: 1.8rem;
	font-weight: 500;
	position: relative;
}
a:before{
	content: '';
	width: 10px;
	height: 10px;
	border-radius: 50px;
	background: #b7986c;
	margin: 0 auto;
	position: absolute;
	top: 8px;
	left: 0;
	right: 0;
	opacity: 0;
	transition: all .3s;
}
a:hover:before{
	content: '';
	position: absolute;
	top: 28px;
	left: 0;
	right: 0;
	opacity: 1;
}

14.下線がのびる(2022/9/21追記)

デモ

HTML

<a href="#">READ MORE</a>

CSS

a{
	display: inline-block;
	font-size: 1.8rem;
	font-weight: 500;
	position: relative;
}
a:before{
	content: '';
	width: 20px;
	height: 4px;
	border-radius: 50px;
	background: #b7986c;
	margin: 0 auto;
	position: absolute;
	top: 26px;
	right: 0;
	left: 0;
	transition: all .3s;
}
a:hover:before{
	content: '';
	width: 100%;
}

15.新しく丸枠が出てくる(2022/11/25追記)

デモ

HTML

<a href="#"><span>MORE</span></a>

CSS

a{
	width: 60px;
	height: 60px;
	display: block;
	background: #111;
	border-radius: 50px;
	text-align: center;
}
a span{
	color: #fff;
	line-height: 60px;
}
a span:after{
	content: '';
	width: 60px;
	height: 60px;
	display: block;
	background: #111;
	border-radius: 50px;
	text-align: center;
	position: relative;
	top: -60px;
	z-index: -1;
	opacity: 0.2;
	transition: all .5s ease-out;
}
a:hover span:after{ transform: scale(1.7); }

16.丸枠が現れる(2022/12/2追記)

デモ

HTML

<a href="#">READ MORE</a>

CSS

a{
	display: inline-block;
	font-size: 18px;
	font-weight: 700;
	position: relative;
}
a:after{
	content: '';
	width: 0;
	height: 0;
	display: block;
	position: absolute;
	top: 50%;
	left: 50%;
	background: rgb(183 152 108 / 0.2);
	border-radius: 50%;
	z-index: -1;
	transition: all .3s ease-out;
	transform: translate(-50%, -50%);
}
a:hover:after {
	width: 70px;
	height: 70px;
	border: 1px solid #b7986c;
}

今後少しずつ追加していく予定です。

関連記事