入力タイプのラジオの入力スタイルを変更しようとしています。ラジオ入力は2つの異なる形式になっています。ラジオ入力は最初のフォームでのみ機能し、2番目のフォームでは機能しません。私はまだ2番目の問題に取り組まない理由で混乱しています。ラジオボタンは1つのフォームでのみ動作し、他のフォームは使用できません
私を助けてください。事前のおかげで
例:https://jsfiddle.net/devefrontend/vaqdsmjk/10/
<input type="radio" name="roundtrip" id="oneway" value="oneway" checked="">
<label for="oneway">Oneway</label>
[type="radio"]:checked,
[type="radio"]:not(:checked) {
position: absolute;
left: -9999px;
}
[type="radio"]:checked + label,
[type="radio"]:not(:checked) + label {
position: relative;
padding-left: 28px;
cursor: pointer;
line-height: 20px;
display: inline-block;
color: #666;
}
[type="radio"]:checked + label:before,
[type="radio"]:not(:checked) + label:before {
content: '';
position: absolute;
left: 0;
top: 0;
width: 18px;
height: 18px;
border: 1px solid #ddd;
border-radius: 100%;
background: #fff;
}
[type="radio"]:checked + label:after,
[type="radio"]:not(:checked) + label:after {
content: '';
width: 12px;
height: 12px;
background: #F87DA9;
position: absolute;
top: 4px;
left: 4px;
border-radius: 100%;
-webkit-transition: all 0.2s ease;
transition: all 0.2s ease;
}
[type="radio"]:not(:checked) + label:after {
opacity: 0;
-webkit-transform: scale(0);
transform: scale(0);
}
[type="radio"]:checked + label:after {
opacity: 1;
-webkit-transform: scale(1);
transform: scale(1);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div role="tabpanel" class="tab-pane active" id="flights">
<form name="flight" method="GET" action="" id="searchFlights" class="form-inline">
<ul class="radio-list">
<li id="radioFlights">
<input type="radio" name="roundtrip" id="oneway" value="oneway" checked="">
<label for="oneway">Oneway</label>
</li>
<li id="radioFlights">
<input type="radio" name="roundtrip" id="return" value="return">
<label for="return">Return</label>
</li>
</ul>
</form>
</div>
<div role="tabpanel" class="tab-pane" id="trains">
<form name="train" method="GET" action="" id="searchTrains" class="form-inline">
<ul class="radio-list">
<li id="radioTrains">
<input type="radio" name="roundtrip" id="oneway" value="oneway" checked="">
<label for="oneway">Oneway</label>
</li>
<li id="radioTrains">
<input type="radio" name="roundtrip" id="return" value="return">
<label for="return">Return</label>
</li>
</ul>
</form>
</div>
IDは一意である必要があります。あなたは同じIDを使っていくつかの要素を持っています。 –