[装飾系]Input checkbox シンプルなチェックボックス

CSS HTML
 2018.02.03
 2018.03.12

シンプルなチェックボックス

ホバーで色が替わるシンプルなチェックボックスです。

browser:  65 11 20 10 
ニャン易度 
<div class="cp_ipcheck">
	<div class="box">
		<input type="checkbox" id="a_ch1" checked />
		<label for="a_ch1">ネコ</label>
		<input type="checkbox" id="a_ch2" />
		<label for="a_ch2">イヌ</label>
		<input type="checkbox" id="a_ch3" />
		<label for="a_ch3">ウサギ</label>
	</div>
</div>
.cp_ipcheck {
	-webkit-box-sizing: border-box;
	        box-sizing: border-box;
}
.cp_ipcheck:before, .cp_ipcheck:after {
	-webkit-box-sizing: inherit;
	        box-sizing: inherit;
}
.cp_ipcheck .box {
	width: 90%;
	margin: 2em auto;
	text-align: left;
	border: 1px solid white;
	border-radius: 3px;
	background: #ffffff;
}
.cp_ipcheck input[type=checkbox] {
	display: none;
}
.cp_ipcheck label:focus,
.cp_ipcheck label:hover,
.cp_ipcheck label:active,
.cp_ipcheck input:checked + label {
	color: #da3c41;
}
.cp_ipcheck label:focus:before,
.cp_ipcheck label:hover:before,
.cp_ipcheck label:active:before,
.cp_ipcheck input:checked + label:before {
	border-color: #da3c41;
	background: #ffffff;
}
.cp_ipcheck label {
	font-size: 1em;
	font-weight: bold;
	line-height: 1;
	position: relative;
	display: block;
	overflow: hidden;
	padding: 1em 1em 1em 3em;
	cursor: pointer;
	-webkit-transition: all 0.15s ease;
	        transition: all 0.15s ease;
	white-space: nowrap;
	text-overflow: ellipsis;
	background: #ffffff;
}
.cp_ipcheck label:before {
	position: absolute;
	top: 1em;
	left: 1em;
	width: 10px;
	height: 10px;
	content: '';
	border: 0.2em solid #cccccc;
}
.cp_ipcheck input:checked + label:before {
	border-color: #da3c41;
	background: #da3c41;
}

copypet.jp

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

More Info

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