您如何使标签文本显示在无线电输入上方?

发布于 2025-02-04 01:43:11 字数 2489 浏览 1 评论 0原文

由于某种原因,当我尝试执行标签>您每周玩几次?< label就在我的无线电输入上方,标签中的文本没有出现。当我在任何其他地方尝试它时,例如在无线电输入的末尾使用它。它仅在收音机输入之前就不起作用。

.bcontainer {
  height: 800px;
  width: 550px;
  background-color: rgba(245, 245, 220, .95);
  margin-left: auto;
  margin-right: auto;
  border-radius: 5px;
  margin-bottom: 15px;
  margin-top: 15px;
  border: 2.5px solid black;
}

label {
  display: block;
  margin: 15px;
  color: black;
  font-family: verdana;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

input {
  width: 100%;
  margin-top: 10px;
  color: white;
  background-color: black;
  border: 1px solid black;
  min-height: 2em;
}


}
.align {
  vertical-align: middle;
  width: unset;
  margin: 0 10px 0 0;
}
<div class="hcontainer">
  <h1 id="title">Game Type Survey</h1>
  <p id="description"><em>Thank you for your response!</em></p>
</div>
<div class="bcontainer">
  <form id="survey-form" action="https://register-demo.freecodecamp.org">
    <fieldset>
      <label id="name-label">Username: <input type="text" name="username" id="name" placeholder="username" required>
            </label>
      <label id="email-label">Email: <input id="email" type="email" name="address" placeholder="email" required>
            </label>
      <label id="number-label">Age: <input id="number" type="number" min="21" max="120" name="age" placeholder="21">
            </label>
      <label>Which Wallet Do You Use? <select name="wallet" id="dropdown" required>
              <option value="">Select Wallet</option>
              <option value="1">MetaMask</option>
                <option value="2">Coinbase</option>
                <option value="3">Wallet Connect</option>
              </fieldset>
              <fieldset>
              <label>How Many Times do you Play Per Week?</label>
      <label><input type="radio" name="#oftimes" class="align" value="1">0-1</label>
      <label><input type="radio" name="#oftimes" class="align" value="2">2-7</label>
      <label><input type="radio" name="#oftimes" class="align" value="3">8+</label>

For some reason when I try to do label> How Many Times do you Play Per Week?<label right above my radio inputs, the text from the label doesn't show up. When I try it in any other place such as at the end of the radio inputs it works. It only doesn't work before the radio inputs.

.bcontainer {
  height: 800px;
  width: 550px;
  background-color: rgba(245, 245, 220, .95);
  margin-left: auto;
  margin-right: auto;
  border-radius: 5px;
  margin-bottom: 15px;
  margin-top: 15px;
  border: 2.5px solid black;
}

label {
  display: block;
  margin: 15px;
  color: black;
  font-family: verdana;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

input {
  width: 100%;
  margin-top: 10px;
  color: white;
  background-color: black;
  border: 1px solid black;
  min-height: 2em;
}


}
.align {
  vertical-align: middle;
  width: unset;
  margin: 0 10px 0 0;
}
<div class="hcontainer">
  <h1 id="title">Game Type Survey</h1>
  <p id="description"><em>Thank you for your response!</em></p>
</div>
<div class="bcontainer">
  <form id="survey-form" action="https://register-demo.freecodecamp.org">
    <fieldset>
      <label id="name-label">Username: <input type="text" name="username" id="name" placeholder="username" required>
            </label>
      <label id="email-label">Email: <input id="email" type="email" name="address" placeholder="email" required>
            </label>
      <label id="number-label">Age: <input id="number" type="number" min="21" max="120" name="age" placeholder="21">
            </label>
      <label>Which Wallet Do You Use? <select name="wallet" id="dropdown" required>
              <option value="">Select Wallet</option>
              <option value="1">MetaMask</option>
                <option value="2">Coinbase</option>
                <option value="3">Wallet Connect</option>
              </fieldset>
              <fieldset>
              <label>How Many Times do you Play Per Week?</label>
      <label><input type="radio" name="#oftimes" class="align" value="1">0-1</label>
      <label><input type="radio" name="#oftimes" class="align" value="2">2-7</label>
      <label><input type="radio" name="#oftimes" class="align" value="3">8+</label>

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

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

发布评论

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

评论(1

你怎么敢 2025-02-11 01:43:11

您尚未关闭&lt; label&gt;&lt; select elements之前。关闭这些,它应该有效,这样:

<label>Which Wallet Do You Use?</label>
<select name="wallet" id="dropdown" required>
  <option value="">Select Wallet</option>
  <option value="1">MetaMask</option>
  <option value="2">Coinbase</option>
  <option value="3">Wallet Connect</option>
</select>

我建议您在选择的代码编辑器上查找如何“自动识别”,或者以其他方式保持完美的凹痕,因为这样的问题真的很容易发现,并且避免了正确的缩进量的缩进:)使一切变得更加整洁,更易于使用!

You haven't closed both the <label> and <select> elements before it. Close those and it should work, like this:

<label>Which Wallet Do You Use?</label>
<select name="wallet" id="dropdown" required>
  <option value="">Select Wallet</option>
  <option value="1">MetaMask</option>
  <option value="2">Coinbase</option>
  <option value="3">Wallet Connect</option>
</select>

I recommend finding out how to 'auto-indent' on your code editor of choice, or otherwise get in the habit of keeping perfect indentation, as issues like these are really easy to spot and avoid when the code is indented correctly :) It also makes everything a lot tidier and easier to work with!

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