html - 如何在一行中对齐文本框和标签

标签 html css css-selectors

这是我的代码 JsFiddle .如何在一行上对齐文本框和标签?

<div class="form-style-10">
   <form action="https://www.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8" method="POST">
      <input type=hidden name="orgid" value="00D90000000qWA6">
      <input type=hidden name="retURL" value="https://google.com">

      <div class="inner-wrap">
         <label for="first_name">First Name*</label>
         <input id="first_name" maxlength="40" name="first_name" size="50" type="text" required />          
      </div>
      <div class="button-section">
         <input type="submit" name="submit">
      </div>
   </form>
</div>

最佳答案

label和input固定宽度,label左浮动

.form-style-10 label{
    width:100px;
    float:left;
}
.form-style-10 input[type="text"], .form-style-10 input[type="date"], .form-style-10 input[type="datetime"], .form-style-10 input[type="email"], .form-style-10 input[type="number"], .form-style-10 input[type="search"], .form-style-10 input[type="time"], .form-style-10 input[type="url"], .form-style-10 input[type="password"], .form-style-10 textarea, .form-style-10 select {
    width: 270px;
}

请查看更新后的jsfiddle

关于html - 如何在一行中对齐文本框和标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27031207/

相关文章:

html - 如何仅影响具有 Last of 类型的 sibling

javascript - 带有单独选择菜单切换的 HTML 下拉菜单

python - bibtex 到 html 与 pybtex,python 3

javascript - HTMLCanvasElement 上 Unresolved 方法 captureStream

html - 如何强制自动设置导航栏宽度?

css - nth-of-type 与 nth-child

php - 区分大小写的 CSS 格式

html - Internet Explorer 8 DOCTYPE 被忽略/评论

javascript - 如何在按下按钮时使 div 翻转?

css - 编写父/子 CSS 的替代/更简洁的方式