源代碼
點擊運行
<!DOCTYPE html> <html> <head> <title>Bootstrap 實例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css"> <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script> <script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script> <script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/js/bootstrap.min.js"></script> </head> <body> <div class="container mt-3"> <h2>輸入框組標籤</h2> <p>在輸入框組通過在輸入框組外圍的 label 來設置標籤,標籤的 for 屬性需要與輸入框組的 id 對應。</p> <p>點擊標籤後可以聚焦輸入框:</p> <form> <label for="demo">這里輸入您的郵箱:</label> <div class="input-group mb-3"> <input type="text" class="form-control" placeholder="Email" id="demo" name="email"> <div class="input-group-append"> <span class="input-group-text">@</span> </div> </div> </form> </div> </body> </html>
運行結果