透過 Bootstrap 在水平佈局中對標籤和窗體控制元件組進行對齊


在 Bootstrap 中使用 .form-horizontal 類以在水平佈局中對齊標籤和窗體控制元件組。

你可以嘗試執行以下程式碼來實現 .form-horizontal

示例

即時演示

<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <form class = "form-horizontal" role = "form">
         <div class = "form-group">
            <label class = "sr-only" for = "name">Name</label>
            <input type = "text" class = "form-control" id = "name" placeholder = "Enter Name">
         </div>
         <div class = "form-group">
            <label class = "sr-only" for = "name">Name</label>
            <input type = "number" class = "form-control" id = "name" placeholder = "Enter Age">
         </div>
         <button type = "submit" class = "btn btn-primary">Submit</button>
      </form>
   </body>
</html>

更新於: 12-06-2020

2K+ 瀏覽量

開啟你的 職業生涯

完成課程並獲得認證

開始
廣告
© . All rights reserved.