gpt4 book ai didi

html - 开关按钮上的不同颜色

转载 作者:搜寻专家 更新时间:2023-10-31 22:41:28 24 4
gpt4 key购买 nike

我有两个 CSS 问题。有没有办法为输入单选"is"和“否”设置不同的颜色?例如红色背景为 NO,蓝色背景为 YES?

如何删除radio之间的空格?

<div class="switch-field">
<input type="radio" id="resetyes" name="reset" value="YES"/>
<label for="resetyes">YES</label>
<input type="radio" id="resetno" name="reset" value="NO"/>
<label for="resetno">NO</label>
</div>

样式.css:

.switch-field {
font-family: Helvetica;
padding: 10px;
overflow: hidden;
}
.switch-title {
margin-bottom: 6px;
}
.switch-field input {
display: none;
}
.switch-field label {
display: inline-block;
width: 60px;
background-color: #F2F0F0;
color: rgba(0, 0, 0, 0.6);
font-size: 14px;
font-weight: bold;
text-align: center;
text-shadow: none;
padding: 6px 14px;
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
-webkit-transition: all 0.1s ease-in-out;
-moz-transition: all 0.1s ease-in-out;
-ms-transition: all 0.1s ease-in-out;
-o-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
.switch-field label:hover {
cursor: pointer;
}
.switch-field input:checked + label {
background-color: #5EA8EE;
-webkit-box-shadow: none;
box-shadow: none;
}
.switch-field label:first-of-type {
border-radius: 4px 0 0 4px;
}
.switch-field label:last-of-type {
border-radius: 0 4px 4px 0;
}

https://jsfiddle.net/t2sof0wd/

最佳答案

只需在您的代码中添加这些 css :-

.switch-field input[value="YES"] + label {
background: green;
}

.switch-field input[value="NO"] + label {
background: red;
}

它可能对你有帮助。

关于html - 开关按钮上的不同颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34507521/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com