为什么我的 CSS only 单选按钮没有被选中?

Why does my CSS only radio button does not get checked?

我正在尝试创建一个 CSS 带有标签的唯一自定义收音机,但我不明白为什么它没有被检查。

我希望当我点击自定义收音机时它应该被选中。 实际上,实际结果是,当我点击自定义收音机时,它没有被选中。

请解释为什么会这样。

非常感谢!

这里是:

.choice {
  display: block;
  width: fit-content;
  margin: 0.25em 0 0 1.5em;
  padding-top: 0.2em;
  padding-left: 0.2em;
  font-size: 1.5em;
  cursor: pointer;
}

.container {
  cursor: pointer;
  top: -0.125em;
  position: relative;
}

input {
  position: absolute;
  opacity: 0;
  visibility: hidden;
}

.checkmark {
  display: inline-block;
  position: relative;
  height: 0.8em;
  width: 0.8em;
  outline-style: none;
  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
  background-color: rgba(0, 0, 0, 0);
  border: 0.1em solid #2185d0;
  border-radius: 50%;
  transition: all 0.5s;
  cursor: pointer;
}

.checkmark:after {
  content: "";
  width: 0.6em;
  height: 0.6em;
  position: relative;
  top: 50%;
  left: 50%;
  background-color: #2185d0;
  border-radius: 50%;
  display: block;
  cursor: pointer;
  transform: translate(-50%, -50%) scale(0);
  transition: all 0.2s;
}

.choice:hover input~.checkmark {
  box-shadow: 0 0 0 0.25em rgba(33, 133, 208, 0.3);
  background-color: rgba(33, 133, 208, 0.3);
}

input[checked]~.checkmark:after {
  transform: translate(-50%, -50%) scale(1);
}
<div class="choice">
  <input type="radio" name="radio" id="radio1" />
  <span class="checkmark"></span>
  <label for="radio1" class="container">One</label>
</div>

谢谢 Temani Afif

:checked 选择器匹配每个选中的元素(仅适用于单选按钮和复选框)和元素。

我错误地使用了 input[checked] 而不是 input:checked

https://www.w3schools.com/cssref/sel_checked.asp