输入类型=“无线电” - 只选择第二个选项?

发布于 2025-01-29 05:30:48 字数 1519 浏览 2 评论 0原文

我的收音机输入有问题。 如果IM单击标签,则可以更改为第二个选项,但对于第一个选项不起作用。我只能选择第一个选项,如果我单击“选择圈”,但我不想显示它。它应该单击文本。 有什么想法吗?

.switch-field {
  display: flex;
  margin-bottom: 36px;
  overflow: hidden;
  justify-content: center;
}

.switch-field input {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  height: 100px;
  width: 100px;
  border: 1px;
  /* overflow: hidden; */
}

.switch-field label {
  background-color: #e4e4e4;
  color: rgba(0, 0, 0, 0.6);
  font-size: 14px;
  line-height: 1;
  text-align: center;
  padding: 8px 10%;
  margin-right: -1px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
  transition: all 0.1s ease-in-out;
}

.switch-field label:hover {
  cursor: pointer;
}

.switch-field input:checked+label {
  background-color: #cc7676;
  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;
}
<div class="switch-field">
  <input type="radio" id="strang1u3" name="switch-one" onchange="speichern(); clicksound()" />
  <label for="strang1u2">Strang 1 & 3</label>
  <input type="radio" id="strang2u4" name="switch-one" onchange="speichern(); clicksound()" />
  <label for="strang2u4">Strang 2 & 4</label>
</div>

I have an issue with my radio input.
It lets me change to the second option if im clicking on the label but it doesnt work for the first option. I can only choose the first option if im clicking on the selection-circle but i dont want to display it. It should work with a click on the text.
Any ideas?

.switch-field {
  display: flex;
  margin-bottom: 36px;
  overflow: hidden;
  justify-content: center;
}

.switch-field input {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  height: 100px;
  width: 100px;
  border: 1px;
  /* overflow: hidden; */
}

.switch-field label {
  background-color: #e4e4e4;
  color: rgba(0, 0, 0, 0.6);
  font-size: 14px;
  line-height: 1;
  text-align: center;
  padding: 8px 10%;
  margin-right: -1px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
  transition: all 0.1s ease-in-out;
}

.switch-field label:hover {
  cursor: pointer;
}

.switch-field input:checked+label {
  background-color: #cc7676;
  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;
}
<div class="switch-field">
  <input type="radio" id="strang1u3" name="switch-one" onchange="speichern(); clicksound()" />
  <label for="strang1u2">Strang 1 & 3</label>
  <input type="radio" id="strang2u4" name="switch-one" onchange="speichern(); clicksound()" />
  <label for="strang2u4">Strang 2 & 4</label>
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

套路撩心 2025-02-05 05:30:48

您的第一个标签(strang1u2)和输入的ID(strang1u3)不匹配。这可能会导致这一点,因为标签与输入不关联。

Your first label's for (strang1u2) and input's id (strang1u3) don't match. This may be causing this as the label isn't associated with the input.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文