[装飾系]テキストリンク アンダーラインからホバーで背景塗りつぶしに切り替わる

CSS HTML
 2018.04.09

アンダーラインからホバーで背景塗りつぶしに切り替わる

browser:  65 11 20 10 
ニャン易度 
テキストリンクテキスト-link text-テキスト
テキスト<a href="#" class="cp_textlink04">リンクテキスト-link text-</a>テキスト
.cp_block {
	margin: 5em auto;
	text-align: center;
}
.cp_textlink04 {
	position: relative;
	padding: 0.1em 0.3em;
	transition: all 0.3s ease;
	text-decoration: none;
	color: #EC407A;
}
.cp_textlink04::before {
	position: absolute;
	content: '';
	left: 0;
	bottom:0;
	width: 100%;
	height: 1%;
	transition: all 0.3s ease;
	opacity: 0;
	background-color: #EC407A;
	border-radius: 50px;
}
.cp_textlink04::after {
	position: absolute;
	bottom: -1px;
	left: 0;
	width: 100%;
	height: 2px;
	content: '';
	transition: all 0.3s ease;
	border-bottom: 2px solid #EC407A;
	opacity: 1;
}
.cp_textlink04:hover::before {
	height: 100%;
	opacity: 0.4;
}
.cp_textlink04:hover::after {
	left: 50%;
	right: 50%;
	width: 0%;
	opacity: 0;
}

copypet.jp

CSS3などで新たに追加された要素・装飾方法など、日々コードを書いていないと忘れてしまったり、ささっとプロトタイプを作る時などちょっとしたことに時間をかけている暇はない。そんな時に「あ〜、あれストックしときゃよかったなぁ」って困った自分用のストックブログです。カスタマイズなどがしやすいよう、昨今のweb制作に取り入れられる一般的なコードを中心に掲載しています。

More Info

こんな記事はいかがですか?