我已经使用下面的CSS样式来设计我的单选框输入框。然而,在Firefox中,出现了完全不同的单选框,并且我无法对其进行样式设置。
在Safari和Chrome中,它能够完美地工作,但我似乎找不出为什么它在Firefox中不起作用的原因。
input[type=checkbox] {
border: 0px;
cursor: pointer;
height: 20px;
margin: 0px 10px 0px 0px;
position: relative;
overflow: hidden;
vertical-align: -5px;
width: 20px;
}
input[type=checkbox]:before {
background-color: transparent;
border: 2px solid #E0E0E0;
content: '';
display: block;
height: 20px;
left: 0px;
opacity: 1;
position: absolute;
transition: opacity .15s linear;
top: 0px;
width: 20px;
}
input[type=checkbox]:after {
border: 2px solid #EC407A;
content: '';
display: block;
height: 23px;
left: -5px;
opacity: 0;
position: absolute;
top: -9px;
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
transition: opacity .15s linear;
width: 27px;
}
input[type=checkbox]:checked:before {
opacity: 0;
}
input[type=checkbox]:checked:after {
opacity: 1;
}
input[type=checkbox]:focus {
box-shadow: none;
outline: 0px;
}
.radio-wrapper {
position: relative;
}
input[type='radio'] {
-webkit-appearance: none;
-moz-appearance: none;
-ms-appearance: none;
-o-appearance: none;
appearance: none;
position: relative;
right: 0;
bottom: 0;
left: 0;
height: 20px;
width: 20px;
-webkit-transition: all 0.15s ease-out 0s;
-moz-transition: all 0.15s ease-out 0s;
transition: all 0.15s ease-out 0s;
background: #cbd1d8;
border: none;
color: #fff;
cursor: pointer;
display: inline-block;
outline: none;
position: relative;
border-radius: 50%;
}
@-webkit-keyframes click-wave {
0% {
height: 40px;
width: 40px;
opacity: 0.35;
position: relative;
}
100% {
height: 200px;
width: 200px;
margin-left: -80px;
margin-top: -80px;
opacity: 0.0;
}
}
@-moz-keyframes click-wave {
0% {
height: 40px;
width: 40px;
opacity: 0.35;
position: relative;
}
100% {
height: 200px;
width: 200px;
margin-left: -80px;
margin-top: -80px;
opacity: 0.0;
}
}
@keyframes click-wave {
0% {
height: 40px;
width: 40px;
opacity: 0.35;
position: relative;
}
100% {
height: 200px;
width: 200px;
margin-left: -80px;
margin-top: -80px;
opacity: 0.0;
}
}
.option-input {
-webkit-transition: all 0.15s ease-out 0s;
-moz-transition: all 0.15s ease-out 0s;
transition: all 0.15s ease-out 0s;
background: #7CE1C9;
border: none;
color: #fff;
cursor: pointer;
display: inline-block;
outline: none;
position: relative;
margin-right: 0.5rem;
}
.option-input:hover {
background: #9faab7;
}
.option-input:checked {
background: #7CE1C9;
}
.option-input:checked::before {
height: 20px;
width: 20px;
position: relative;
content: '\2716';
display: inline-block;
font-size: 14.66667px;
text-align: center;
line-height: 20px;
}
.option-input:checked::after {
-webkit-animation: click-wave 0.65s;
-moz-animation: click-wave 0.65s;
animation: click-wave 0.65s;
background: #7CE1C9;
content: '';
display: block;
position: relative;
}
.option-input.radio {
border-radius: 50%;
}
.option-input.radio::after {
border-radius: 50%;
}
input[type='radio'] + label {
user-select: none;
cursor: pointer;
padding-left: 30px;
}
input[type='radio'] + label:before,
input[type='radio'] + label:after {
background: #fff;
background-clip: padding-box;
border: 2px solid #EC407A;
border-radius: 50%;
bottom: 3px;
content: '';
display: block;
height: 16px;
left: 3px;
margin-top: -8px;
position: absolute;
top: 50%;
transition: all 0.3s ease;
width: 16px;
}
input[type='radio'] + label:after {
background: #7CE1C9;
border: 2px solid #fff;
transform: scale(0);
-wekbit-transform: scale(0);
transition: all 0.3s ease;
}
input[type='radio']:focus + label:before {
box-shadow: 0 0 5px #EC407A;
}
input[type='radio']:checked + label:before {
border-color: #EC407A;
}
input[type='radio']:checked + label:after {
transform: scale(0.75, 0.75);
-webkit-transform: scale(0.75, 0.75);
}
`
<form>
<li class='initialForm'><span class='optionText'>$option1</span><strong><input type='radio' class='option-input radio option1' id='$id' value='1' name='option'></strong>
</li>
<li class='initialForm'><span class='optionText'>$option2</span><strong><input type='radio' class='option-input radio option2' id='$id' value='2' name='option'></strong>
</li>
</form>
input[type='radio']:checked + label:after
,但是你的label
在哪里呢? - dippas