【Bootstrap V4系列】学习入门教程之 组件-输入组(Input group)

news2025/7/16 7:43:09

Bootstrap V4系列 学习入门教程之 组件-输入组(Input group)

  • 输入组(Input group)
    • Basic example
    • 一、Wrapping 包装
    • 二、Sizing 尺寸
    • 三、Multiple addons 多个插件
    • 四、Button addons 按钮插件
    • 五、Buttons with dropdowns 带下拉按钮
    • 六、Custom forms 自定义表单
      • 6.1 Custom select 自定义选择
      • 6.2 Custom file input 自定义文件输入

输入组(Input group)

通过在文本输入、自定义选择和自定义文件输入的任一侧添加文本、按钮或按钮组,可以轻松扩展表单控件。

Basic example

在输入的两侧放置一个插件或按钮。您也可以在输入的两侧放置一个。记住将<label>s放在输入组之外。

<!--Basic example-->
<div class="input-group mb-3">
    <div class="input-group-prepend">
        <span class="input-group-text" id="basic-addon1">@</span>
    </div>
    <input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
</div>

<div class="input-group mb-3">
    <input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
    <div class="input-group-append">
        <span class="input-group-text" id="basic-addon2">@example.com</span>
    </div>
</div>

<label for="basic-url">Your vanity URL</label>
<div class="input-group mb-3">
    <div class="input-group-prepend">
        <span class="input-group-text" id="basic-addon3">https://example.com/users/</span>
    </div>
    <input type="text" class="form-control" id="basic-url" aria-describedby="basic-addon3">
</div>

<div class="input-group mb-3">
    <div class="input-group-prepend">
        <span class="input-group-text">$</span>
    </div>
    <input type="text" class="form-control" aria-label="Amount (to the nearest dollar)">
    <div class="input-group-append">
        <span class="input-group-text">.00</span>
    </div>
</div>

<div class="input-group">
    <div class="input-group-prepend">
        <span class="input-group-text">With textarea</span>
    </div>
    <textarea class="form-control" aria-label="With textarea"></textarea>
</div>

页面展示效果:

在这里插入图片描述

一、Wrapping 包装

默认情况下,输入组通过flex-wrap:wrap 进行包装,以适应输入组内的自定义表单字段验证。您可以使用.flex-nowrap 禁用此功能。

<div class="input-group flex-nowrap">
  <div class="input-group-prepend">
    <span class="input-group-text" id="addon-wrapping">@</span>
  </div>
  <input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="addon-wrapping">
</div>

页面展示效果:

在这里插入图片描述

二、Sizing 尺寸

将相对的表单大小类添加到.input-group 组本身,其中的内容将自动调整大小——不需要在每个元素上重复表单控件大小类。

不支持对单个输入组元素进行大小调整。

<div class="input-group input-group-sm mb-3">
  <div class="input-group-prepend">
    <span class="input-group-text" id="inputGroup-sizing-sm">Small</span>
  </div>
  <input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm">
</div>

<div class="input-group mb-3">
  <div class="input-group-prepend">
    <span class="input-group-text" id="inputGroup-sizing-default">Default</span>
  </div>
  <input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-default">
</div>

<div class="input-group input-group-lg">
  <div class="input-group-prepend">
    <span class="input-group-text" id="inputGroup-sizing-lg">Large</span>
  </div>
  <input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-lg">
</div>

页面展示效果:

在这里插入图片描述

三、Multiple addons 多个插件

支持多个附加组件,可以与复选框和单选框输入版本混合使用。

<div class="input-group mb-3">
  <div class="input-group-prepend">
    <span class="input-group-text">$</span>
    <span class="input-group-text">0.00</span>
  </div>
  <input type="text" class="form-control" aria-label="Dollar amount (with dot and two decimal places)">
</div>

<div class="input-group">
  <input type="text" class="form-control" aria-label="Dollar amount (with dot and two decimal places)">
  <div class="input-group-append">
    <span class="input-group-text">$</span>
    <span class="input-group-text">0.00</span>
  </div>
</div>

页面展示效果:

在这里插入图片描述

四、Button addons 按钮插件

<div class="input-group mb-3">
  <div class="input-group-prepend">
    <button class="btn btn-outline-secondary" type="button" id="button-addon1">Button</button>
  </div>
  <input type="text" class="form-control" placeholder="" aria-label="Example text with button addon" aria-describedby="button-addon1">
</div>

<div class="input-group mb-3">
  <input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="button-addon2">
  <div class="input-group-append">
    <button class="btn btn-outline-secondary" type="button" id="button-addon2">Button</button>
  </div>
</div>

<div class="input-group mb-3">
  <div class="input-group-prepend" id="button-addon3">
    <button class="btn btn-outline-secondary" type="button">Button</button>
    <button class="btn btn-outline-secondary" type="button">Button</button>
  </div>
  <input type="text" class="form-control" placeholder="" aria-label="Example text with two button addons" aria-describedby="button-addon3">
</div>

<div class="input-group">
  <input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username with two button addons" aria-describedby="button-addon4">
  <div class="input-group-append" id="button-addon4">
    <button class="btn btn-outline-secondary" type="button">Button</button>
    <button class="btn btn-outline-secondary" type="button">Button</button>
  </div>
</div>

页面展示效果:

在这里插入图片描述

五、Buttons with dropdowns 带下拉按钮

<div class="input-group mb-3">
  <div class="input-group-prepend">
    <button class="btn btn-outline-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-expanded="false">Dropdown</button>
    <div class="dropdown-menu">
      <a class="dropdown-item" href="#">Action</a>
      <a class="dropdown-item" href="#">Another action</a>
      <a class="dropdown-item" href="#">Something else here</a>
      <div role="separator" class="dropdown-divider"></div>
      <a class="dropdown-item" href="#">Separated link</a>
    </div>
  </div>
  <input type="text" class="form-control" aria-label="Text input with dropdown button">
</div>

<div class="input-group">
  <input type="text" class="form-control" aria-label="Text input with dropdown button">
  <div class="input-group-append">
    <button class="btn btn-outline-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-expanded="false">Dropdown</button>
    <div class="dropdown-menu">
      <a class="dropdown-item" href="#">Action</a>
      <a class="dropdown-item" href="#">Another action</a>
      <a class="dropdown-item" href="#">Something else here</a>
      <div role="separator" class="dropdown-divider"></div>
      <a class="dropdown-item" href="#">Separated link</a>
    </div>
  </div>
</div>

页面展示效果:

在这里插入图片描述

六、Custom forms 自定义表单

输入组包括对自定义选择和自定义文件输入的支持。不支持这些的浏览器默认版本。

6.1 Custom select 自定义选择

<div class="input-group mb-3">
  <div class="input-group-prepend">
    <label class="input-group-text" for="inputGroupSelect01">Options</label>
  </div>
  <select class="custom-select" id="inputGroupSelect01">
    <option selected>Choose...</option>
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>
  </select>
</div>

<div class="input-group mb-3">
  <select class="custom-select" id="inputGroupSelect02">
    <option selected>Choose...</option>
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>
  </select>
  <div class="input-group-append">
    <label class="input-group-text" for="inputGroupSelect02">Options</label>
  </div>
</div>

<div class="input-group mb-3">
  <div class="input-group-prepend">
    <button class="btn btn-outline-secondary" type="button">Button</button>
  </div>
  <select class="custom-select" id="inputGroupSelect03" aria-label="Example select with button addon">
    <option selected>Choose...</option>
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>
  </select>
</div>

<div class="input-group">
  <select class="custom-select" id="inputGroupSelect04" aria-label="Example select with button addon">
    <option selected>Choose...</option>
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>
  </select>
  <div class="input-group-append">
    <button class="btn btn-outline-secondary" type="button">Button</button>
  </div>
</div>

页面展示效果:

在这里插入图片描述

6.2 Custom file input 自定义文件输入

此示例使用自定义文件浏览器组件,该组件依赖于单独的 bs-custom-file-input 自定义文件输入插件。

<div class="input-group mb-3">
  <div class="input-group-prepend">
    <span class="input-group-text" id="inputGroupFileAddon01">Upload</span>
  </div>
  <div class="custom-file">
    <input type="file" class="custom-file-input" id="inputGroupFile01" aria-describedby="inputGroupFileAddon01">
    <label class="custom-file-label" for="inputGroupFile01">Choose file</label>
  </div>
</div>

<div class="input-group mb-3">
  <div class="custom-file">
    <input type="file" class="custom-file-input" id="inputGroupFile02">
    <label class="custom-file-label" for="inputGroupFile02" aria-describedby="inputGroupFileAddon02">Choose file</label>
  </div>
  <div class="input-group-append">
    <span class="input-group-text" id="inputGroupFileAddon02">Upload</span>
  </div>
</div>

<div class="input-group mb-3">
  <div class="input-group-prepend">
    <button class="btn btn-outline-secondary" type="button" id="inputGroupFileAddon03">Button</button>
  </div>
  <div class="custom-file">
    <input type="file" class="custom-file-input" id="inputGroupFile03" aria-describedby="inputGroupFileAddon03">
    <label class="custom-file-label" for="inputGroupFile03">Choose file</label>
  </div>
</div>

<div class="input-group">
  <div class="custom-file">
    <input type="file" class="custom-file-input" id="inputGroupFile04" aria-describedby="inputGroupFileAddon04">
    <label class="custom-file-label" for="inputGroupFile04">Choose file</label>
  </div>
  <div class="input-group-append">
    <button class="btn btn-outline-secondary" type="button" id="inputGroupFileAddon04">Button</button>
  </div>
</div>

页面展示效果:

在这里插入图片描述

自定义文件输入插件:

<script src="https://cdn.jsdelivr.net/npm/bs-custom-file-input/dist/bs-custom-file-input.js"></script>

您应该等待文档就绪事件,并调用init方法使您的自定义文件输入动态。我们公开了一个随处可用的全局变量:bsCustomFileInput

<script>
    $(document).ready(function () {
        bsCustomFileInput.init()
    })
</script>

一切准备就绪后,你应该看到页面的上传效果:

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2373379.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

VS “筛选器/文件夹”

每天学习一个VS小技巧&#xff1a; 我在VS创建筛选器的时候&#xff0c;想要想要同步计算机上的文件目录&#xff0c;但是发现并未 同步。 例如我在这儿创建了一个筛选器IoManager 但是在UI这个文件夹里并未创建对应的IoManager文件夹 我右击也没有打开文件所在位置 然后我…

powerbuilder9.0中文版

经常 用这个版本号写小软件,非常喜欢这个开发软件 . powerbuilder9.0 非常的小巧,快捷,功能强大,使用方便. 我今天用软件 自己汉化了一遍&#xff0c;一些常用的界面都已经翻译成中文。 我自己用的&#xff0c;以后有什么界面需要翻译&#xff0c;再更新一下。 放在这里留个…

基于C语言的TCP通信测试程序开发指南

一、TCP通信基础原理 1.1 通信流程概述 TCP通信采用客户端-服务器模型&#xff0c;核心流程如下&#xff1a; 服务器端&#xff1a; 创建套接字&#xff08;Socket&#xff09; 绑定地址和端口&#xff08;Bind&#xff09; 开始监听&#xff08;Listen&#xff09; 接受…

教育系统源码如何支持白板直播与刷题功能?功能开发与优化探索

很多行业内同学疑问&#xff0c;如何在教育系统源码中支持白板直播和刷题功能&#xff1f;本篇文章&#xff0c;小编将从功能设计、技术实现到性能优化&#xff0c;带你全面了解这个过程。 一、白板直播功能的核心需求与技术挑战 实时交互与同步性 白板直播的核心是“实时性”。…

再度深入理解PLC的输入输出接线

本文再次重新梳理&#xff1a; 两线式/三线式传感器的原理及接线、PLC的输入和输出接线&#xff0c;深入其内部原理&#xff0c;按照自己熟悉的方式去理解该知识 在此之前&#xff0c;需要先统一几个基础知识点&#xff1a; 在看任何电路的时候&#xff0c;需要有高低电压差&…

k8s(11) — 探针和钩子

钩子和探针的区别&#xff1a; 在 Kubernetes&#xff08;k8s&#xff09;中&#xff0c;钩子&#xff08;Hooks&#xff09;和探针&#xff08;Probes&#xff09;是保障应用稳定运行的重要机制&#xff0c;不过它们的用途和工作方式存在差异&#xff0c;以下为你详细介绍&…

使用jmeter对数据库进行压力测试

&#x1f345; 点击文末小卡片 &#xff0c;免费获取软件测试全套资料&#xff0c;资料在手&#xff0c;涨薪更快 前言 很多人提到 jmeter时&#xff0c;只会说到jmeter进行接口自动化或接口性能测试&#xff0c;其实jmeter还能对数据库进行自动化操作。个人常用的场景有以下&…

Kubernetes生产实战(十四):Secret高级使用模式与安全实践指南

一、Secret核心类型解析 类型使用场景自动管理机制典型字段Opaque (默认)自定义敏感数据需手动创建data字段存储键值对kubernetes.io/dockerconfigjson私有镜像仓库认证kubelet自动更新.dockerconfigjsonkubernetes.io/tlsTLS证书管理Cert-Manager可自动化tls.crt/tls.keykube…

05 mysql之DDL

一、SQL的四个分类 我们通常可以将 SQL 分为四类&#xff0c;分别是&#xff1a; DDL&#xff08;数据定义语言&#xff09;、DML&#xff08;数据操作语言&#xff09;、 DCL&#xff08;数据控制语言&#xff09;和 TCL&#xff08;事务控制语言&#xff09;。 DDL 用于创建…

电池热管理CFD解决方案,为新能源汽车筑安全防线

在全球能源结构加速转型的大背景下&#xff0c;新能源汽车产业异军突起&#xff0c;成为可持续发展的重要驱动力。而作为新能源汽车 “心脏” 的电池系统&#xff0c;其热管理技术的优劣&#xff0c;直接决定了车辆的安全性、续航里程和使用寿命。电池在充放电过程中会产生大量…

TransmittableThreadLocal:穿透线程边界的上下文传递艺术

文章目录 前言一、如何线程上下文传递1.1 ThreadLocal单线程1.2 InheritableThreadLocal的继承困境1.3 TTL的时空折叠术 二、TTL核心设计解析2.1 时空快照机制2.2 装饰器模式2.3 采用自动清理机制 三、设计思想启示四、实践启示录结语 前言 在并发编程领域&#xff0c;线程上下…

基于STM32的甲醛检测

一、制作目标 以正点原子的miniSTM32F103RCT6开发板为主控&#xff0c;使用甲醛传感器检测环境空气中的甲醛含量&#xff08;以mg/m^3为单位&#xff09;、C02含量&#xff08;以ppm为单位&#xff09;和总有机挥发物含量TVOC&#xff08;以mg/m^3为单位&#xff09;在OLED显示…

洛图报告中的 FSHD 是什么?—— 解密九天画芯推动的三色光源显示技术

目录 一、洛图报告新焦点&#xff1a;FSHD 为何成为显示产业重要突破方向&#xff1f; &#xff08;一&#xff09;洛图报告核心结论&#xff1a;从技术突围到产业重构 二、技术解析&#xff1a;FSHD 如何重构显示底层逻辑&#xff1f; &#xff08;一&#xff09;物理架构…

【MySQL】事务(重点)

目录 一、什么是事务&#xff1a; 二、事务的前置知识了解 引擎是否支持事务 事务的提交方式 事务操作的前置准备&#xff1a; 三、事务回滚&#xff1a; 四、事务崩溃&#xff1a; 原子性&#xff1a; 持久性&#xff1a; 五、自动提交和手动提交&#xff1a; 六、…

Linux:线程同步与互斥

目录 线程互斥 锁 初始化 销毁 加锁 解锁 线程同步 条件变量 初始化 销毁 等待条件满足 唤醒等待 pthread_cond_signal pthread_cond_broadcast 生产者消费者模型 3种关系 2种角色 1个交易场所 POSIX信号量 初始化 销毁 等待 发布 线程互斥 互斥相关…

每天五分钟机器学习:拉格朗日对偶函数

本文重点 在数学优化领域,拉格朗日对偶函数作为连接原始约束问题与对偶问题的核心纽带,展现了将复杂约束优化转化为无约束优化的方式。 数学表达 原始问题建模 拉格朗日函数构造 此时的目标就是: 先假设w为常数,让拉格朗日函数对橙子变量λ求极大值,消掉λ之后,在对λ求…

AutoGen 框架解析:微软开源的多人 Agent 协作新范式

一、引言 在大语言模型&#xff08;LLM&#xff09;快速发展的今天&#xff0c;复杂任务的自动化协作需求日益增长。微软开源的AutoGen 框架&#xff08;GitHub Star 超 10 万&#xff09;提供了一种基于多智能体对话的协作范式&#xff0c;通过自然语言交互实现多角色 Agent …

【bibtex4word】在Word中高效转换bib参考文献,Texlive环境安装bibtex4word插件

前言 现已退出科研界&#xff0c;本人水货一个。希望帮到有缘人 本篇关于如何将latex环境中的参考文献bib文件转化为word&#xff0c;和一些踩坑记录。 可以看下面的资料进行配置&#xff0c;后面的文字是这些资料的补充说明。 参考文章&#xff1a;https://blog.csdn.net/g…

单片机-STM32部分:10-2、逻辑分析仪

飞书文档https://x509p6c8to.feishu.cn/wiki/VrdkwVzOnifH8xktu3Bcuc4Enie 安装包如下&#xff1a;根据自己的系统选择&#xff0c;目前这个工具只有window版本哦 安装方法比较简单&#xff0c;都按默认下一步即可&#xff0c;注意不要安装到中文路径哦。 其余部分参考飞书文档…

计算机网络基础科普

IP地址是计算机网络中标识设备的唯一地址 IPv4&#xff08;32位&#xff09;IPv6&#xff08;128位&#xff09; 1.IPv4&#xff08;32位&#xff09; 简介&#xff1a;IPv4&#xff08;Internet Protocol version 4&#xff09;是互联网协议&#xff08;IP&#xff09;的…