フォームはサイトにはかならず必要になってくるアイテムですが、わかりやすく間違えにくいものにしたいですよね。
チェックボックス[input type=”checkbox”]のデザインにエフェクトを追加することで、
今までよりワンランク上のわかりやすさを手に入れましょう。
<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;
}
<div class="cp_ipcheck">
<label>
<input type="checkbox" class="option-input02 checkbox" checked />
ネコ
</label>
<label>
<input type="checkbox" class="option-input02 checkbox" />
イヌ
</label>
<label>
<input type="checkbox" class="option-input02 checkbox" />
ウサギ
</label>
</div>
.cp_ipcheck {
width: 90%;
margin: 2em auto;
text-align: left;
}
@keyframes click-wave {
0% {
position: relative;
width: 30px;
height: 30px;
opacity: 0.35;
}
100% {
width: 200px;
height: 200px;
margin-top: -80px;
margin-left: -80px;
opacity: 0;
}
}
.cp_ipcheck .option-input02 {
position: relative;
top: 13.33333px;
right: 0;
bottom: 0;
left: 0;
width: 30px;
height: 30px;
margin-right: 0.5rem;
cursor: pointer;
transition: all 0.15s ease-out 0s;
color: #ffffff;
border: none;
outline: none;
background: #d7cbcb;
-webkit-appearance: none;
appearance: none;
}
.cp_ipcheck .option-input02:hover {
background: #d6a9a9;
}
.cp_ipcheck .option-input02:checked {
background: #da3c41;
}
.cp_ipcheck .option-input02:checked::before {
font-size: 20px;
line-height: 30px;
position: absolute;
display: inline-block;
width: 30px;
height: 30px;
content: '✔';
text-align: center;
}
.cp_ipcheck .option-input02:checked::after {
position: relative;
display: block;
content: '';
-webkit-animation: click-wave 0.65s;
animation: click-wave 0.65s;
background: #da3c41;
}
.cp_ipcheck .option-input02.radio {
border-radius: 50%;
}
.cp_ipcheck .option-input02.radio::after {
border-radius: 50%;
}
.cp_ipcheck label {
line-height: 40px;
display: block;
}
.cp_ipcheck .option-input02:disabled {
cursor: not-allowed;
background: #b8b7b7;
}
.cp_ipcheck .option-input02:disabled::before {
font-size: 20px;
line-height: 30px;
position: absolute;
display: inline-block;
width: 30px;
height: 30px;
content: '✖︎';
text-align: center;
}
<div class="cp_ipcheck">
<input type="checkbox" id="b_ch1" checked />
<label for="b_ch1">ネコ</label>
<input type="checkbox" id="b_ch2" />
<label for="b_ch2">イヌ</label>
<input type="checkbox" id="b_ch3" />
<label for="b_ch3">ウサギ</label>
</div>
.cp_ipcheck {
width: 90%;
margin: 2em auto;
text-align: left;
}
.cp_ipcheck input[type='checkbox'] {
position: absolute;
z-index: -1;
opacity: 0;
}
.cp_ipcheck label {
position: relative;
display: inline-block;
margin-right: 30px;
padding-right: 10px;
padding-left: 35px;
cursor: pointer;
}
.cp_ipcheck label::before {
position: absolute;
z-index: -1;
top: 0;
left: 0;
display: block;
width: 24px;
height: 24px;
content: ' ';
border: 2px solid #da3c41;
}
.cp_ipcheck input[type='checkbox'] + label::before {
border-radius: 4px;
}
.cp_ipcheck input[type='checkbox']:checked + label {
padding-left: 10px;
color: #ffffff;
}
.cp_ipcheck input[type='checkbox']:checked + label::before {
top: 0;
width: 100%;
height: 100%;
background: #da3c41;
}
/* Transition */
.cp_ipcheck label, .cp_ipcheck label::before {
-webkit-transition: 0.25s all ease;
transition: 0.25s all ease;
}
<div class="cp_ipcheck">
<input type="checkbox" id="c_ch1" checked />
<label for="c_ch1">ネコ</label>
<input type="checkbox" id="c_ch2" />
<label for="c_ch2">イヌ</label>
<input type="checkbox" id="c_ch3" />
<label for="c_ch3">ウサギ</label>
</div>
.cp_ipcheck {
width: 20%;
margin: 2em auto;
text-align: left;
}
.cp_ipcheck input {
display: none;
}
.cp_ipcheck label {
position: relative;
display: block;
padding: 15px 0;
padding-right: 35px;
cursor: pointer;
}
.cp_ipcheck input[type='checkbox'] {
position: absolute;
visibility: hidden !important;
}
.cp_ipcheck input[type='checkbox'] + label:before,
.cp_ipcheck input[type='checkbox'] + label:after {
position: absolute;
top: 50%;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin-top: -7.5px;
content: '';
}
.cp_ipcheck input[type='checkbox'] + label:before {
right: 0;
width: 30px;
height: 15px;
border: 1px solid #e4e3e1;
border-radius: 15px;
background: #ffffff;
}
.cp_ipcheck input[type='checkbox'] + label:after {
right: 15px;
width: 15px;
height: 15px;
-webkit-transition: all 200ms ease-out;
transition: all 200ms ease-out;
border-radius: 50%;
background: #bdbdbd;
}
.cp_ipcheck input[type='checkbox']:checked + label:after {
right: 0;
background: #da3c41;
}
<div class="cp_ipcheck">
<ul>
<li class="list_item">
<label>
<input type="checkbox" class="option-input05" checked />
ネコ
</label>
</li>
<li class="list_item">
<label>
<input type="checkbox" class="option-input05" />
イヌ
</label>
</li>
<li class="list_item">
<label>
<input type="checkbox" class="option-input05" />
ウサギ
</label>
</li>
</ul>
</div>
.cp_ipcheck {
width: 90%;
margin: 2em auto;
text-align: left;
}
.cp_ipcheck ul {
margin: 0.5rem 0.5rem 2rem 0.5rem;
padding: 0.5rem 1rem;
list-style: none;
border: 1px solid #cccccc;
}
.cp_ipcheck .list_item {
margin: 0 0 0.5rem 0;
padding: 0;
}
.cp_ipcheck label {
line-height: 135%;
position: relative;
margin: 0.5rem;
cursor: pointer;
}
.cp_ipcheck .option-input05 {
position: relative;
margin: 0 1rem 0 0;
cursor: pointer;
}
.cp_ipcheck .option-input05:before {
position: absolute;
z-index: 1;
top: 0.125rem;
left: 0.1875rem;
width: 0.75rem;
height: 0.375rem;
content: '';
-webkit-transition: -webkit-transform 0.4s cubic-bezier(0.45, 1.8, 0.5, 0.75);
transition: transform 0.4s cubic-bezier(0.45, 1.8, 0.5, 0.75);
-webkit-transform: rotate(-45deg) scale(0, 0);
transform: rotate(-45deg) scale(0, 0);
border: 2px solid #da3c41;
border-top-style: none;
border-right-style: none;
}
.cp_ipcheck .option-input05:checked:before {
-webkit-transform: rotate(-45deg) scale(1, 1);
transform: rotate(-45deg) scale(1, 1);
}
.cp_ipcheck .option-input05:after {
position: absolute;
top: -0.125rem;
left: 0;
width: 1rem;
height: 1rem;
content: '';
cursor: pointer;
border: 2px solid #f2f2f2;
background: #ffffff;
}
<div class="cp_ipcheck">
<ul>
<li class="list_item">
<label>
<input type="checkbox" class="option-input06" checked />
ネコ
</label>
</li>
<li class="list_item">
<label>
<input type="checkbox" class="option-input06" />
イヌ
</label>
</li>
<li class="list_item">
<label>
<input type="checkbox" class="option-input06" />
ウサギ
</label>
</li>
</ul>
</div>
.cp_ipcheck {
width: 90%;
margin: 2em auto;
text-align: left;
}
.cp_ipcheck ul {
margin: 0.5rem 0.5rem 2rem 0.5rem;
padding: 0.5rem 1rem;
list-style: none;
border: 1px solid #cccccc;
}
.cp_ipcheck .list_item {
margin: 0 0 0.5rem 0;
padding: 0;
}
.cp_ipcheck label {
line-height: 135%;
position: relative;
margin: 0.5rem;
padding-left: 1rem;
cursor: pointer;
}
.cp_ipcheck .option-input06 {
position: relative;
top: -0.375rem;
margin: 0 1rem 0 0;
cursor: pointer;
outline: none;
-webkit-appearance: none;
}
.cp_ipcheck .option-input06:before, .option-input06:after {
position: absolute;
z-index: 1;
top: -0.0625rem;
left: -1rem;
width: 1rem;
height: 1rem;
content: '';
-webkit-transition: -webkit-transform 0.4s ease-in-out, border-top 0.4s ease-in-out, border-bottom 0.4s ease-in-out, border-left 0.1s 0.3s ease-in-out, border-right 0.1s 0.3s ease-in-out;
transition: transform 0.4s ease-in-out, border-top 0.4s ease-in-out, border-bottom 0.4s ease-in-out, border-left 0.1s 0.3s ease-in-out, border-right 0.1s 0.3s ease-in-out;
-webkit-transform: translateX(0) translateY(-0.5rem);
transform: translateX(0) translateY(-0.5rem);
border: 2px solid #f2f2f2;
border-top-style: none;
border-right-style: none;
}
.cp_ipcheck .option-input06:after {
z-index: 0;
border: 2px solid #f2f2f2;
border-bottom-style: none;
border-left-style: none;
}
.cp_ipcheck .option-input06:checked:before {
-webkit-transform: rotate(-45deg) translateX(0.25rem) translateY(-0.75rem);
transform: rotate(-45deg) translateX(0.25rem) translateY(-0.75rem);
border-color: #e74c3c;
border-left-style: none;
}
.cp_ipcheck .option-input06:checked:after {
-webkit-transform: rotate(45deg) translateX(-0.25rem) translateY(0.25rem);
transform: rotate(45deg) translateX(-0.25rem) translateY(0.25rem);
border-color: #e74c3c;
border-right-style: none;
}
<div class="cp_ipcheck">
<ul>
<li class="list_item">
<label>
<input type="checkbox" class="option-input07" checked />
ネコ
</label>
</li>
<li class="list_item">
<label>
<input type="checkbox" class="option-input07" />
イヌ
</label>
</li>
<li class="list_item">
<label>
<input type="checkbox" class="option-input07" />
ウサギ
</label>
</li>
</ul>
</div>
.cp_ipcheck {
width: 90%;
margin: 2em auto;
text-align: left;
}
.cp_ipcheck ul {
margin: 0.5rem 0.5rem 2rem 0.5rem;
padding: 1rem 1rem 0.5rem 1rem;
list-style: none;
border: 1px solid #cccccc;
}
.cp_ipcheck .list_item {
margin: 0 0 0.5rem 0;
padding: 0;
}
.cp_ipcheck label {
line-height: 135%;
position: relative;
margin: 0.5rem;
cursor: pointer;
}
.cp_ipcheck .option-input07 {
position: relative;
top: -0.375rem;
margin: 0 1rem 0 0;
cursor: pointer;
outline: none;
}
.cp_ipcheck .option-input07:before, .cp_ipcheck .option-input07:after {
position: absolute;
z-index: 1;
top: -0.125rem;
left: -0.125rem;
width: 1rem;
height: 1rem;
content: '';
-webkit-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
border: 2px solid #da3c41;
background: #ffffff;
}
.cp_ipcheck .option-input07:after {
z-index: 0;
border: none;
}
.cp_ipcheck .option-input07:checked:before {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
background: #da3c41;
}
<div class="cp_ipcheck">
<ul>
<li class="list_item">
<input type="checkbox" class="option-input" id="d_ch1" checked />
<label for="d_ch1">ネコ</label>
</li>
<li class="list_item">
<input type="checkbox" class="option-input" id="d_ch2" />
<label for="d_ch2">イヌ</label>
</li>
<li class="list_item">
<input type="checkbox" class="option-input" id="d_ch3" />
<label for="d_ch3">ウサギ</label>
</li>
</ul>
</div>
.cp_ipcheck {
width: 90%;
margin: 2em auto;
text-align: left;
}
.cp_ipcheck ul {
margin: 0;
padding: 0;
list-style: none;
}
.cp_ipcheck .list_item {
position: relative;
}
.cp_ipcheck .list_item:hover label {
color: #da3c41;
}
.cp_ipcheck .list_item:hover label::before {
margin-right: 2em;
border: 0.4em solid #da3c41;
}
.cp_ipcheck .option-input {
display: none;
}
.cp_ipcheck .option-input:checked + label {
color: #da3c41;
}
.cp_ipcheck .option-input:checked + label::before {
margin-right: 2em;
border: 0.4em solid #da3c41;
background: #da3c41;
}
.cp_ipcheck label {
display: -webkit-box;
display: flex;
padding: 1em 0;
cursor: pointer;
-webkit-transition: all 0.25s linear;
transition: all 0.25s linear;
text-transform: uppercase;
-webkit-box-align: center;
align-items: center;
}
.cp_ipcheck label::before {
display: block;
width: 1em;
height: 1em;
margin-right: 0.625em;
content: '';
-webkit-transition: all 0.25s linear;
transition: all 0.25s linear;
border: 0.4em solid #da3c41;
}
.cp_ipcheck .option-input:disabled + label {
cursor: not-allowed;
color: #b8b7b7;
}
.cp_ipcheck .option-input:disabled + label::before {
cursor: not-allowed;
border: 0.4em solid #b8b7b7;
}
<div class="cp_ipcheck">
<label for="d_rb1">
<input type="checkbox" id="d_rb1" checked />
<div>ネコ<span>猫</span></div>
</label>
<label for="d_rb2">
<input type="checkbox" id="d_rb2" />
<div>イヌ<span>犬</span></div>
</label>
<label for="d_rb3">
<input type="checkbox" id="d_rb3" />
<div>ウサギ<span>兎</span></div>
</label>
<label for="d_rb4">
<input type="checkbox" id="d_rb4" />
<div>トリ<span>鳥</span></div>
</label>
<label for="d_rb5">
<input type="checkbox" id="d_rb5" />
<div>リス<span>栗鼠</span></div>
</label>
</div>
.cp_ipcheck {
width: 90%;
margin: 2em auto;
text-align: left;
}
.cp_ipcheck label {
position: relative;
display: block;
width: 100%;
margin: 2px 0 0;
padding: 10px 0;
}
.cp_ipcheck label input[type='checkbox'] {
position: relative;
z-index: 1;
display: inline-block;
float: left;
margin-top: 3px;
margin-right: 15px;
}
.cp_ipcheck label input[type='checkbox']:checked + div span {
position: absolute;
top: -5px;
left: 100%;
display: inline-block;
visibility: visible;
clear: both;
margin: 0 0 0 20px;
padding: 8px 15px;
transition: transform 200ms ease;
transform: translateX(0px);
text-align: center;
white-space: nowrap;
color: #ffffff;
border-radius: 4px;
background-color: rgba(34, 34, 34, 0.9);
box-shadow: 0 0 10px rgba(34, 34, 34, 0.2);
}
.cp_ipcheck label input[type='checkbox']:checked + div span:before {
position: absolute;
top: 4px;
left: -1px;
content: '';
transform: rotate(45deg);
border-top: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid rgba(34, 34, 34, 0.9);
}
.cp_ipcheck label div {
position: relative;
display: inline-block;
}
.cp_ipcheck label div span {
position: absolute;
visibility: hidden;
transition: transform 200ms ease;
transform: translateX(-10px);
}
.cp_ipcheck label:nth-of-type(1) input[type='checkbox']:checked + div span {
background-color: #2e9b72;
}
.cp_ipcheck label:nth-of-type(1) input[type='checkbox']:checked + div span:before {
border-top: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid rgba(46,156,114, 0.9);
}
.cp_ipcheck label:nth-of-type(2) input[type='checkbox']:checked + div span {
background-color: #36509a;
}
.cp_ipcheck label:nth-of-type(2) input[type='checkbox']:checked + div span:before {
border-top: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid rgba(54,80,154, 0.9);
}
.cp_ipcheck label:nth-of-type(3) input[type='checkbox']:checked + div span {
background-color: #f7c735;
}
.cp_ipcheck label:nth-of-type(3) input[type='checkbox']:checked + div span:before {
border-top: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid rgba(247,199,53, 0.9);
}
.cp_ipcheck label:nth-of-type(4) input[type='checkbox']:checked + div span {
background-color: #a62e7a;
}
.cp_ipcheck label:nth-of-type(4) input[type='checkbox']:checked + div span:before {
border-top: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid rgba(166,46,122, 0.9);
}
.cp_ipcheck label:nth-of-type(5) input[type='checkbox']:checked + div span {
background-color: #da3c41;
}
.cp_ipcheck label:nth-of-type(5) input[type='checkbox']:checked + div span:before {
border-top: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid rgba(218,60,65, 0.9);
}
コピペでできる!cssとhtmlのみでフォームのラジオボタンをわかりやすくするデザイン10選 | copypet.jp|パーツで探す、web制作に使えるコピペサイト。
フォームはサイトにはかならず必要になってくるアイテムですが、わかりやすく間違えにくいものにしたいですよね。 ラジオボタン[input type="radio"]のデザインにエフェクトを追加することで、 今までよりワンランク上のわかりやすさを手に入れましょう。…CSS3などで新たに追加された要素・装飾方法など、日々コードを書いていないと忘れてしまったり、ささっとプロトタイプを作る時などちょっとしたことに時間をかけている暇はない。そんな時に「あ〜、あれストックしときゃよかったなぁ」って困った自分用のストックブログです。カスタマイズなどがしやすいよう、昨今のweb制作に取り入れられる一般的なコードを中心に掲載しています。
@copypet_jp More Info