[装飾系]テキストリンク ホバーで外側から枠が表示される

CSS HTML
 2018.04.09

ホバーで外側から枠が表示される

browser:  65 11 20 10 
ニャン易度 
テキストリンクテキスト-link text-テキスト
テキスト<a href="#" class="cp_textlink07">リンクテキスト-link text-</a>テキスト
.cp_block {
	margin: 5em auto;
	text-align: center;
}
.cp_textlink07 {
	position: relative;
	display: inline-block;
	padding: 0.1em 0.3em;
	text-decoration: none;
	color: #9C27B0;
}
.cp_textlink07::after,
.cp_textlink07::before {
	position: absolute;
	content: '';
	border-radius: 3px;
}
.cp_textlink07::after {
	bottom: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(156,39,176 ,.4);
	transition: all 0.3s ease;
}
.cp_textlink07::before {
	top: -4px;
	bottom: -5px;
	left: -4px;
	right: -5px;
	width: calc(100% + 6px);
	height: calc(100% + 6px);
	border: 1px solid #9C27B0;
	opacity: 0;
	transition: all 0.3s;
}
.cp_textlink07:hover:after {
	background: rgba(156,39,176 ,.2);
}
.cp_textlink07:hover:before {
	top: 2px;
	left: 2px;
	width: calc(100% - 6px);
	height: calc(100% - 6px);
	opacity: 1;
}

copypet.jp

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

More Info

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