我正在做一个项目,我需要背景的复选框是黄色和颜色的滴答白色。
<div class="radio-btn">
<input type="checkbox" name="disclaimer" id="rad-1" required="" />
<label for="rad-1">Yes, please!</label>
</div>这是我的HTML,它的样式写在下面
#rad-1 {
height: 20px;
width: 20px;
accent-color: yellow;
}背景变黄了,但滴答的颜色变黑了,我试过“颜色:白色”和“背景颜色:白色”,但是这些工作和滴答标记都没有保持黑色。
这是看上去的样子

发布于 2022-03-23 14:57:54
我给您留下一个可能的例子:如何-自定义复选框
首先,我们隐藏浏览器的默认单选按钮
.container input {
position: absolute;
opacity: 0;
cursor: pointer;
}现在我们创建一个自定义单选按钮
.checkmark {
position: absolute;
top: 0;
left: 0;
height: 25px;
width: 25px;
background-color: #eee;
border-radius: 50%;
}完整示例
body {
background-color: grey;
}
/* The container */
.container {
display: block;
position: relative;
padding-left: 35px;
margin-bottom: 12px;
cursor: pointer;
font-size: 22px;
color: white;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Hide the browser's default radio button */
.container input {
position: absolute;
opacity: 0;
cursor: pointer;
}
/* Create a custom radio button */
.checkmark {
position: absolute;
top: 0;
left: 0;
height: 25px;
width: 25px;
background-color: #eee;
border-radius: 50%;
}
/* On mouse-over, add a grey background color */
.container:hover input~.checkmark {
background-color: #ccc;
}
/* When the radio button is checked, add a blue background */
.container input:checked~.checkmark {
background-color: yellow;
}
/* Create the indicator (the dot/circle - hidden when not checked) */
.checkmark:after {
content: "";
position: absolute;
display: none;
}
/* Show the indicator (dot/circle) when checked */
.container input:checked~.checkmark:after {
display: block;
}
/* Style the indicator (dot/circle) */
.container .checkmark:after {
top: 9px;
left: 9px;
width: 8px;
height: 8px;
border-radius: 50%;
background: white;
}<h1>Custom Radio Buttons</h1>
<label class="container">One
<input type="radio" checked="checked" name="radio">
<span class="checkmark"></span>
</label>
<label class="container">Two
<input type="radio" name="radio">
<span class="checkmark"></span>
</label>
<label class="container">Three
<input type="radio" name="radio">
<span class="checkmark"></span>
</label>
<label class="container">Four
<input type="radio" name="radio">
<span class="checkmark"></span>
</label>
发布于 2022-03-23 14:28:35
我不得不将一些样式应用到复选框中,并面临许多挑战。下面的链接帮助了我,请看一看。
发布于 2022-03-23 14:12:41
没有有效的方法来做到这一点(就我现在而言),但是有一些像https://doodlenerd.com/html-control/css-checkbox-generator这样的收费来生成自定义复选框,您可以在这里编辑很多东西。
当您使用标签单击自定义指示器时,它们将被激活。
https://stackoverflow.com/questions/71588463
复制相似问题