Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Thiết lập chiều cao và chiều rộng Form với Bootstrap

Sử dụng các lớp như .input-lg và .col-lg-* để thiết lập chiều cao và chiều rộng của form.

Ví dụ

Bạn có thể chạy mã sau để thiết lập chiều cao và chiều rộng form:

<!DOCTYPE html> <html>    <head>       <title>Ví dụ Bootstrap</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 role = "form">          <div class = "form-group">             <input class = "form-control input-lg" type = "text" placeholder =".input-lg">          </div>          <div class = "form-group">             <input class = "form-control" type = "text" placeholder = "Input mặc định">          </div>          <div class = "form-group">             <input class = "form-control input-sm" type = "text" placeholder = ".input-sm">          </div>          <div class = "form-group"></div>          <div class = "form-group">             <select class = "form-control input-lg">                <option value = "">.input-lg</option>             </select>          </div>          <div class = "form-group">             <select class = "form-control">                <option value = "">Select mặc định</option>             </select>          </div>          <div class = "form-group">             <select class = "form-control input-sm">                <option value = "">.input-sm</option>             </select>          </div>          <div class = "row">             <div class = "col-lg-2">                <input type = "text" class = "form-control" placeholder = ".col-lg-2">             </div>             <div class = "col-lg-3">                <input type = "text" class = "form-control" placeholder = ".col-lg-3">             </div>             <div class = "col-lg-4">                <input type = "text" class = "form-control" placeholder = ".col-lg-4">             </div>          </div>       </form>    </body> </html>

Giải thích các lớp:

  • .input-lg, .input-sm: Điều chỉnh chiều cao của input/select (Bootstrap 3)
  • .col-lg-*: Hệ thống lưới Bootstrap để điều chỉnh chiều rộng cột
  • Bootstrap 4/5: Sử dụng .form-control-lg, .form-control-sm và các lớp lưới responsive