Bootstrap5 表单输入组

表单输入组

https://getbootstrap.com/docs/5.3/forms/input-group/

.input-group 类是一种容器,通过在输入字段的前面或后面添加图标、文字或按钮作为“帮助文本”来增强输入。
.input-group-text 类指定帮助文本的样式。

例如:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="bootstrap5/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
</head>

<body>
  <div class="container">
    <form action="">
      <div class="input-group">
        <input type="text" class="form-control" placeholder="请输入邮箱">
        <span class="input-group-text">@yeah.net</span>
      </div>
    </form>
  </div>

  <script src="bootstrap5/js/bootstrap.bundle.min.js"></script>
</body>

</html>

在这里插入图片描述

输入组的大小

https://getbootstrap.com/docs/5.3/forms/input-group/#sizing

.input-group-sm用于小型输入组,.input-group-lg用于大型输入组。

例如:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="bootstrap5/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
</head>

<body>
  <div class="container">
    <form action="">
      <div class="input-group">
        <input type="text" class="form-control" placeholder="请输入邮箱">
        <span class="input-group-text">@yeah.net</span>
      </div>
      <div class="input-group input-group-sm">
        <input type="text" class="form-control" placeholder="请输入邮箱">
        <span class="input-group-text">@yeah.net</span>
      </div>
      <div class="input-group input-group-lg">
        <input type="text" class="form-control" placeholder="请输入邮箱">
        <span class="input-group-text">@yeah.net</span>
      </div>
    </form>
  </div>

  <script src="bootstrap5/js/bootstrap.bundle.min.js"></script>
</body>

</html>

在这里插入图片描述

多个输入

https://getbootstrap.com/docs/5.3/forms/input-group/#multiple-inputs

尽管系统在视觉上能够处理多个<input>元素,但是验证样式功能仅限于那些包含单一<input>元素的输入组。

例如:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="bootstrap5/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
</head>

<body>
  <div class="container">
    <form action="">
      <div class="input-group">
        <span class="input-group-text">请输入姓名:</span>
        <input type="text" class="form-control" placeholder="姓">
        <input type="text" class="form-control" placeholder="名">
      </div>
    </form>
  </div>

  <script src="bootstrap5/js/bootstrap.bundle.min.js"></script>
</body>

</html>

在这里插入图片描述

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值