使用Bootstrap,为什么这些标签和输入控件不会在同一行上显示



为什么标签和字段(只是输入的包装器)不显示在同一行上?

我相信我正在按照此处找到的简单说明:https://www.w3schools.com/bootstrap/bootstrap/bootstrap_grid_medium.asp

<div className="container">
    <div className="row">
        <label htmlFor="something" className="col-sm-2 col-form-label">Somethingwefwef</label>
        <Field className="col-sm-10" name="something" type="text" component="input" className="form-control" />
    </div>
</div>

您的整个标记是有问题的。尝试仔细遵循教程。

您应该像这样做

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
          <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
           <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
           <style type="text/css">
            
           </style>
           </head>
           <body>
            <div class="container">
    <div class="row">
        <label For="something" class="col-sm-2 form-label">Somethingwefwef</label>
        <input class="col-sm-10" name="something" type="text"  class="form-control" />
    </div>
</div>
  </body>
  </html>

最新更新