Bootstrap 输入组的使用

htmlbootstrapjqueryweb development更新于 2026/2/11 0:44:17

通过在输入字段中添加前置和后置内容,您可以为用户输入添加常用元素。例如,您可以添加美元符号、Twitter 用户名的 @,或任何其他可能在您的应用程序界面中常见的元素。

示例

您可以尝试运行以下代码来创建 Bootstrap 输入组

<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Input Group</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>
      <div style = "padding: 100px 100px 10px;">
         <form class = "bs-example bs-example-form" role = "form">
            <div class = "input-group">
               <span class = "input-group-addon">@</span>
               <input type = "text" class = "form-control" placeholder = "twitterhandle">
            </div>
            <br>
            <div class = "input-group">
               <input type = "text" class = "form-control">
               <span class = "input-group-addon">.00</span>
            </div>
            <br>
            <div class = "input-group">
                span class = "input-group-addon">$</span>
               <input type = "text" class =" form-control">
               <span class = "input-group-addon">.00</span>
            </div>
         </form>
      </div>
   </body>
</html>

有用资源