html - 对齐标签旁边的文本框

标签 html css

我有一个文本框在标签下方对齐。但我需要将文本框与标签对齐。

我正在添加一个代码片段。

<div class="row">
  <div class="col-sm-4 form-group col-md-4 col-xs-12">
    <div class="form-group">
      <label id="label" class="control-label">Total Work days in Current Month:</label>
      <input type="text" class="form-control" name="header" ng-model="currentmonth" placeholder="Enter the details" autocomplete="off" required />
    </div>
  </div>
</div>

有什么帮助吗?

最佳答案

试试这个:

阅读更多关于 form-inlineform-horizo​​ntal here

HTML:

<form class="form-inline">
  <div class="form-group">
    <label for="exampleInputName2">Name</label>
    <input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
  </div>
  <div class="form-group">
    <label for="exampleInputEmail2">Email</label>
    <input type="email" class="form-control" id="exampleInputEmail2" placeholder="jane.doe@example.com">
  </div>
  <button type="submit" class="btn btn-default">Send invitation</button>
</form>

使用form-horizo​​ntal

<form class="form-horizontal">
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
    <div class="col-sm-10">
      <input type="password" class="form-control" id="inputPassword3" placeholder="Password">
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <div class="checkbox">
        <label>
          <input type="checkbox"> Remember me
        </label>
      </div>
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default">Sign in</button>
    </div>
  </div>
</form>

关于html - 对齐标签旁边的文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41820045/

相关文章:

html - 如果没有 display "list-item"CSS display "list"有什么用?

html - 为什么我的图片底部不对齐?

javascript - 如何使用 PHP GET 请求打开 Bootstrap 模式?

javascript - Cordova 错误 : Refused to execute inline script because it violates the following Content Security Policy directive

javascript - 如何使用 scrollTop() 制作反向动画;

PHP 在 10 分钟不活动后自动注销

javascript - jQuery 在点击事件上 undefined variable

jquery - 将元素放在另一个元素旁边?

html - 无法更改文本间距和 float 以更改文本位置

html - 如何减少 Bootstrap 网格系统的代码?