<main class="main-wrapper">
<fieldset class="fieldset">
<legend>ラジオボタンはフォーカスしたら方向キーで選択操作</legend>
<input type="radio" id="radio1" name="radio1" checked class="radio">
<label for="radio1">ラジオボタン1</label>
<input type="radio" id="radio2" name="radio1" class="radio">
<label for="radio2">ラジオボタン2</label>
<input type="radio" id="radio3" name="radio1" class="radio" disabled>
<label for="radio3" disabled>非活性ラジオボタン</label>
</fieldset>
<p>※キーボード操作時のみフォーカス・インジケーターにスタイル適用</p>
</main>
<main class="main-wrapper">
<fieldset class="fieldset">
<legend>ラジオボタンはフォーカスしたら方向キーで選択操作</legend>
<input type="radio" id="radio1" name="radio1" checked class="radio">
<label for="radio1">ラジオボタン1</label>
<input type="radio" id="radio2" name="radio1" class="radio">
<label for="radio2">ラジオボタン2</label>
<input type="radio" id="radio3" name="radio1" class="radio" disabled>
<label for="radio3" disabled>非活性ラジオボタン</label>
</fieldset>
<p>※キーボード操作時のみフォーカス・インジケーターにスタイル適用</p>
</main>
/* No context defined. */
.fieldset {
width: 65%;
margin-bottom: 1.5rem;
font-size: calc(var(--font-size-m2));
}
.fieldset:not(:first-of-type) {
margin-top: 1rem;
}
.radio {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
border: 0;
white-space: nowrap;
overflow: hidden;
clip: rect(0 0 0 0);
clip-path: inset(50%);
}
.radio + label {
display: block;
position: relative;
width: auto;
margin-top: 1rem;
padding-left: 1.8em;
line-height: 1.75;
cursor: pointer;
}
.radio:checked + label {
font-weight: bold;
color: #000098;
}
.radio:hover + label,
.radio:focus + label {
opacity: .75;
transition: all .15s ease-in;
}
.radio + label:before {
content: "";
display: inline-block;
position: absolute;
top: 50%;
left: 0;
width: 1.5rem;
height: 1.5rem;
border: 2px solid #888;
background-color: #fff;
transform: translateY(-50%);
border-radius: 50%;
border-radius: 50%;
box-sizing: border-box;
}
.radio:checked + label:after {
content: "";
display: inline-block;
position: absolute;
top: 50%;
left: 4px;
width: 1rem;
height: 1rem;
background: #000098;
transform: translateY(-50%);
border-radius: 50%;
}
.radio:checked + label:after {
opacity: 1;
animation: scale-radio .2s ease-in-out normal running;
}
.radio:disabled,
.radio + label[disabled] {
opacity: .67;
cursor: not-allowed;
}
@-webkit-keyframes scale-radio {
0% {
top: 43%;
transform: scale(.75) translateY(-50%);
}
10% {
top: 43%;
transform: scale(.75) translateY(-50%);
}
83% {
top: 50%;
transform: scale(1) translateY(-50%);
}
100% {
top: 50%;
transform: scale(1) translateY(-50%);
}
}
@keyframes scale-radio {
0% {
top: 43%;
transform: scale(.75) translateY(-50%);
}
10% {
top: 43%;
transform: scale(.75) translateY(-50%);
}
83% {
top: 50%;
transform: scale(1) translateY(-50%);
}
100% {
top: 50%;
transform: scale(1) translateY(-50%);
}
}
No notes defined.