按钮(Buttons) · Bootstrap v4 中文文档 v4.6

您所在的位置:网站首页 buttons耳机故障 按钮(Buttons) · Bootstrap v4 中文文档 v4.6

按钮(Buttons) · Bootstrap v4 中文文档 v4.6

2024-07-16 23:37:18| 来源: 网络整理| 查看: 265

View on GitHub 按钮(Buttons)

Use Bootstrap’s custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.

示例

Bootstrap 内置了几种预定义的按钮样式,每种样式都有自己的语义目的,并添加了一些额外的按钮includes several predefined button styles, each serving its own semantic purpose, with a few extras thrown in for more control.

Primary Secondary Success Danger Warning Info Light Dark Link Conveying meaning to assistive technologies

Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .sr-only class.

禁止按钮上的文字换行

如果你不希望按钮中的文字换行的话,可以为按钮添加 .text-nowrap 类。在 Sass 代码中,你可以设置 $btn-white-space: nowrap 来禁止所有按钮中的文本换行。

可用作按钮的 HTML 标签

.btn 系列类(class)被设计为用于 元素。不过,你也可以将这些类用于 或 元素(但是某些浏览器可能会使用略有不同的渲染方式)。

当 .btn 系列类(class)用于 元素并触发页面上的功能(例如折叠内容),而不是链接到新页面或当前页面中的内容部分时,应当为这些链接设置 role="button" 属性,以便将链接的目的以适当的方式传递给类似屏幕阅读器的辅助工具。

Link Link Button 带轮廓线的按钮

当你需要使用按钮,但不希望按钮带有背景颜色时,请将默认的修饰符类(modifier class)替换为 .btn-outline-* 系列类(class),已去除按钮上的所有背景图片和颜色。

Primary Secondary Success Danger Warning Info Light Dark 某些按钮的样式使用了相对较浅的前景色,因此仅应在深色背景上使用才能具有足够的对比度。 按钮的尺寸

需要更大或更小的按钮吗?使用 .btn-lg 或 .btn-sm 类可以设置按钮的不同尺寸。

Large button Large button Small button Small button

通过添加 .btn-block 类来创建块级按钮(即,按钮占满了整个父级元素的宽度)。

Block level button Block level button 活动状态

当按钮处于活动状态时,按钮将表现为被按下的效果,即背景和边框变暗,如果启用了阴影效果,将会有 inset 阴影。由于这一效果是基于伪类(pseudo-class)实现的,因此无需为 添加任何类(class)。但是,如果需要以编程方式强制复现这一效果的话,可以使用 .active 类(并设置 aria-pressed=“true” 属性)。

Primary link Link Primary link Link 禁用状态

通过为 元素设置 disabled 属性(此属性是布尔类型的)可以使按钮看起来处于不可用状态。

Primary button Button

使用 元素创建的处于禁用状态的按钮具有些许不同的行为:

元素不支持 disabled 属性,因此必须设置 .disabled 类以使其在外观上显示为禁用状态。 包含了一些并未被全面支持的的属性,用于禁止按钮上的所有 鼠标事件(pointer-events) 。在支持这些属性的浏览器中,光标移动到被禁用的按钮上时将不会出现变化(即不会变为手的样子)。 利用 标签实现的禁用按钮应当设置 aria-disabled="true" 属性,以便向辅助技术提供当前元素的状态。 利用 标签实现的禁用按钮 不应 设置 href 属性。 Primary link Link Primary link Link Link functionality caveat

To cover cases where you have to keep the href attribute on a disabled link, the .disabled class uses pointer-events: none to try to disable the link functionality of s. Note that this CSS property is not yet standardized for HTML, but all modern browsers support it. In addition, even in browsers that do support pointer-events: none, keyboard navigation remains unaffected, meaning that sighted keyboard users and users of assistive technologies will still be able to activate these links. So to be safe, in addition to aria-disabled="true", also include a tabindex="-1" attribute on these links to prevent them from receiving keyboard focus, and use custom JavaScript to disable their functionality altogether.

Primary link Link Primary link Link 按钮插件

Do more with buttons. Control button states or create groups of buttons for more components like toolbars.

切换状态

添加 data-toggle="button" 以切换按钮的 active 状态。如果要预先切换的状态,则必须手动为 元素添加 .active 类 和 aria-pressed="true" 属性。

Single toggle Checkbox and radio buttons

Bootstrap’s .button styles can be applied to other elements, such as s, to provide checkbox or radio style button toggling. Add data-toggle="buttons" to a .btn-group containing those modified buttons to enable their toggling behavior via JavaScript and add .btn-group-toggle to style the s within your buttons. Note that you can create single input-powered buttons or groups of them.

The checked state for these buttons is only updated via click event on the button. If you use another method to update the input—e.g., with or by manually applying the input’s checked property—you’ll need to toggle .active on the manually.

Note that pre-checked buttons require you to manually add the .active class to the input’s .

Checked Active Radio Radio 方法 方法 描述 $().button('toggle') Toggles push state. Gives the button the appearance that it has been activated. $().button('dispose') Destroys an element’s button.


【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭