我需要我的单选按钮有一个方形的格式,保持每一个的背景色。
我尝试的是添加“.定制无线电输入类型=”收音机“+标签跨度”:
-webkit-外观:复选框; -moz-外观:复选框; -ms-外观:复选框;
但这去掉了背景色。
.custom-radios div {
display: inline-block;
}
.custom-radios input[type="radio"] {
display: none;
}
.custom-radios input[type="radio"] + label {
color: #333;
font-family: Arial, sans-serif;
font-size: 14px;
}
.custom-radios input[type="radio"] + label span {
display: inline-block;
width: 25px;
height: 25px;
margin: -1px 4px 0 0;
vertical-align: middle;
cursor: pointer;
border-radius: 50%;
border: 2px solid #fff;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.33);
background-repeat: no-repeat;
background-position: center;
text-align: center;
line-height: 25px;
}
.custom-radios input[type="radio"] + label span img {
opacity: 0;
transition: all 0.3s ease;
}
.custom-radios input[type="radio"]#color-3 + label span {
background-color: #f1c40f;
}
.custom-radios input[type="radio"]#color-4 + label span {
background-color: #e74c3c;
}
.custom-radios input[type="radio"]:checked + label span img {
opacity: 1;
}<div class="custom-radios">
<div>
<input type="radio" id="color-3" name="color" value="color-3">
<label for="color-3">
<span>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/242518/check-icn.svg" alt="Checked Icon" />
</span>
</label>
</div>
<div>
<input type="radio" id="color-4" name="color" value="color-4">
<label for="color-4">
<span>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/242518/check-icn.svg" alt="Checked Icon" />
</span>
</label>
</div>
</div>
发布于 2019-07-30 19:03:54
移除边界半径:50%;
.custom-radios div {
display: inline-block;
}
.custom-radios input[type="radio"] {
display: none;
}
.custom-radios input[type="radio"] + label {
color: #333;
font-family: Arial, sans-serif;
font-size: 14px;
}
.custom-radios input[type="radio"] + label span {
display: inline-block;
width: 25px;
height: 25px;
margin: -1px 4px 0 0;
vertical-align: middle;
cursor: pointer;
/*border-radius: 50%;*/
border: 2px solid #fff;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.33);
background-repeat: no-repeat;
background-position: center;
text-align: center;
line-height: 25px;
}
.custom-radios input[type="radio"] + label span img {
opacity: 0;
transition: all 0.3s ease;
}
.custom-radios input[type="radio"]#color-3 + label span {
background-color: #f1c40f;
}
.custom-radios input[type="radio"]#color-4 + label span {
background-color: #e74c3c;
}
.custom-radios input[type="radio"]:checked + label span img {
opacity: 1;
}<div class="custom-radios">
<div>
<input type="radio" id="color-3" name="color" value="color-3">
<label for="color-3">
<span>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/242518/check-icn.svg" alt="Checked Icon" />
</span>
</label>
</div>
<div>
<input type="radio" id="color-4" name="color" value="color-4">
<label for="color-4">
<span>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/242518/check-icn.svg" alt="Checked Icon" />
</span>
</label>
</div>
</div>
发布于 2019-07-30 19:07:59
试着做这样的事情:
input[type="radio"] {
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
outline: 0;
background: lightgray;
height: 16px;
width: 16px;
border: 1px solid white;
}
input[type="radio"]:checked {
background: #aaaaaa;
}
input[type="checkbox"]:hover {
filter: brightness(90%);
}
input[type="checkbox"]:disabled {
background: #e6e6e6;
opacity: 0.6;
pointer-events: none;
}
input[type="radio"]:after {
content: '';
position: relative;
left: 40%;
top: 20%;
width: 15%;
height: 40%;
border: solid #fff;
border-width: 0 2px 2px 0;
transform: rotate(45deg);
display: none;
}
input[type="radio"]:checked:after {
display: block;
}
input[type="radio"]:disabled:after {
border-color: #7b7b7b;
}<label><input type="radio" name="radio"> Checkbox 1</label>
<label><input type="radio" name="radio"> Checkbox 2</label>
发布于 2019-07-30 19:07:09
只要给边境线-半径0%
.custom-radios input[type="radio"] + label span {
display: inline-block;
width: 25px;
height: 25px;
margin: -1px 4px 0 0;
vertical-align: middle;
cursor: pointer;
border-radius: 0%;
border: 2px solid #fff;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.33);
background-repeat: no-repeat;
background-position: center;
text-align: center;
line-height: 25px;
}https://stackoverflow.com/questions/57278417
复制相似问题