gpt4 book ai didi

html - 造型 radio 输入问题

转载 作者:太空宇宙 更新时间:2023-11-04 02:19:00 25 4
gpt4 key购买 nike

我想在“标签”标签内设置单选输入的样式。我已经改变了背景颜色,但是当我点击我的 radio 时,里面的白点没有出现。我为此编写了代码,但我真的不知道问题出在哪里。

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
label {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin-right: 15px;
font-size: 13px;
display:block;
}

input[type=radio] {
display: none;
}

label:before {
content: "";
display: inline-block;
width: 17px;
height: 17px;
margin-right: 10px;
position: absolute;
left: 0;
bottom: 1px;
background-color: #ff7900;
box-shadow: inset 0px 2px 3px 0px rgba(0, 0, 0, .3), 0px 1px 0px 0px rgba(255, 255, 255, .8);
border-radius: 8px;
}

input[type=radio]:checked + label:before {
content: "\2022";
color: #f3f3f3;
font-size: 30px;
text-align: center;
line-height: 18px;
position: absolute;
}

.input {
font-size: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<form>
<label class="input"><input type="radio" name="number" class="hehe">xxxxxxxx</label>
<label class="input" ><input type="radio" name="number" class="hehe">xxxxxxx</label>
<label class="input"><input type="radio" name="number" class="hehe">xxxxxxx</label>\
<label class="input"><input type="radio" name="number" class="hehe">xxxxxxx</label>
</form>
</body>
</html>

最佳答案

这个:

input[type=radio]:checked + label:before

要求 label 紧跟在输入之后。

但是,您的 HTML 是

 <label class="input"><input type="radio" name="number" class="hehe">xxxxxxxx</label>

标签围绕着输入,因此选择器将不起作用。

你需要

<input type="radio" name="number" class="hehe"/><label class="input">xxxxxxxx</label>

或者;在标签内的 span 上使用伪元素而不是标签本身

 <label class="input">
<input type="radio" name="number" class="hehe">
<span>xxxxxxxx</span>
</label>

input[type=radio]:checked + span:before

关于html - 造型 radio 输入问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38436395/

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