html - 如何在标签旁边放置单选按钮

标签 html css

我已经开始学习网络开发的基础知识,目前正在尝试 html 和 css。我的问题是如何使单选按钮出现在标签(问题)的右侧,就像它出现在图片的左侧一样。现在我所能做的就是在右边。你能帮帮我吗?

enter image description here

这是我的CSS:

@import url(https://fonts.googleapis.com/css?family=Raleway:400,500);
body {
  background-color: #a9d7d1;
  font-family: Raleway;
  text-align: center;
  min-width: 320px;
}

#title {
  text-weight: bold;
  font-size: 50px;
  margin: 20px;
}

#center {
  margin: 0 auto;
  background-color: rgb(250, 250, 250);
  width: 60%;
  border: 0px solid;
  border-radius: 5%;
}

#description {
  padding-top: 30px;
}

#name-label,
#email-label,
#age-label,
#Role-label,
#userRating-label,
#most-like-label,
#preferences-label #comments-label {
  padding: 10px;
  display: inline-block;
  vertical-align: center;
}

#submit {
  color: white;
  background-color: #59ace0;
  border-radius: 5%;
  border: 0px solid;
  height: 40px;
  width: 100px;
  margin: 20px;
}

textarea {
  width: 30%;
}

.dropdown {
  height: 35px;
  width: 140px;
  padding: 5px;
  margin: 10px;
  margin-top: 15px;
  border: 1px solid #c0c0c0;
  border-radius: 2px;
}

#name,
#email,
#age {
  height: 20px;
  width: 200px;
  padding: 5px;
  margin: 10px;
  margin-top: 15px;
  border: 1px solid #c0c0c0;
  border-radius: 2px;
}

textarea {
  vertical-align: top;
}

li {
  padding: 5px;
}
<div id="preferences-div">

  <label for="preferences" name="preferences" id="preferences-label">Things that should be improved in the future<br>(Check all that apply):</label>

  <ul id="preferences" style="list-style: none;">
    <li class="checkbox"><label><input name="prefer" value="1" type="checkbox" class="userRatings">Front-end Projects</label></li>
    <li class="checkbox"><input name="prefer" value="2" type="checkbox" class="userRatings">Back-end Projects</li>
    <li class="checkbox"><label><input name="prefer" value="3" type="checkbox" class="userRatings">Data Visualization</label></li>
    <li class="checkbox"><label><input name="prefer" value="4" type="checkbox" class="userRatings">Challenges</label></li>
    <li class="checkbox"><label><input name="prefer" value="5" type="checkbox" class="userRatings">Open Source Community</label></li>
    <li class="checkbox"><label><input name="prefer" value="6" type="checkbox" class="userRatings">Gitter help rooms</label></li>
    <li class="checkbox"><label><input name="prefer" value="7" type="checkbox" class="userRatings">Videos</label></li>
    <li class="checkbox"><label><input name="prefer" value="8" type="checkbox" class="userRatings">City Meetups</label></li>
    <li class="checkbox"><label><input name="prefer" value="9" type="checkbox" class="userRatings">Wiki</label></li>
    <li class="checkbox"><label><input name="prefer" value="10" type="checkbox" class="userRatings">Forum</label></li>
    <li class="checkbox"><label><input name="prefer" value="10" type="checkbox" class="userRatings">Additional Courses</label></li>
  </ul>
</div>

最佳答案

最终解决方案:

#preferences {
  display: inline-block;
  list-style: none;
}

#preferences-label {
  display: inline-block;
  vertical-align: top;
}
<div id="preferences-div">

    <label for="preferences" name="preferences" id="preferences-label">Things that should be improved in the future<br>(Check all that apply):</label>

    <ul id="preferences">
      <li class="checkbox"><label><input name="prefer" value="1" type="checkbox" class="userRatings">Front-end Projects</label></li>
      <li class="checkbox"><input name="prefer" value="2" type="checkbox" class="userRatings">Back-end Projects</li>
      <li class="checkbox"><label><input name="prefer" value="3" type="checkbox" class="userRatings">Data Visualization</label></li>
      <li class="checkbox"><label><input name="prefer" value="4" type="checkbox" class="userRatings">Challenges</label></li>
      <li class="checkbox"><label><input name="prefer" value="5" type="checkbox" class="userRatings">Open Source Community</label></li>
      <li class="checkbox"><label><input name="prefer" value="6" type="checkbox" class="userRatings">Gitter help rooms</label></li>
      <li class="checkbox"><label><input name="prefer" value="7" type="checkbox" class="userRatings">Videos</label></li>
      <li class="checkbox"><label><input name="prefer" value="8" type="checkbox" class="userRatings">City Meetups</label></li>
      <li class="checkbox"><label><input name="prefer" value="9" type="checkbox" class="userRatings">Wiki</label></li>
      <li class="checkbox"><label><input name="prefer" value="10" type="checkbox" class="userRatings">Forum</label></li>
      <li class="checkbox"><label><input name="prefer" value="10" type="checkbox" class="userRatings">Additional Courses</label></li>
    </ul>
  </div>

关于html - 如何在标签旁边放置单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53655025/

相关文章:

javascript - Span 悬停不起作用以及如何更改 div 外部元素的属性

html - 如何在 html 列表中的不同元素之间添加不同大小的间隙?

jQuery 导航插件刷新整个页面。我该如何解决

javascript - 在 SVG 圆圈内环绕文本

HTML 表格最大单元格边框半径

javascript - Windows 商店应用程序 - 元素背景颜色

html - Bootstrap slider 宽度父级(12 个断点)

html - 在 Cordova/Ionic 中放大特定的 div

python - 如何在 HTML/CSS 中整齐地格式化代码?如果可以的话,我特别想使用 Python Docutils 的数字圆标注

python - INFO : Crawled 0 pages (at 0 pages/min), 抓取了 0 件元素(0 件/分钟)