Bootstrap4 支持以下表单控件:
Bootstrap 支持所有的 HTML5 输入类型: text, password, datetime, datetime-local, date, month, time, week, number, email, url, search, tel, 以及 color。
注意:: 如果 input 的 type 属性未正确声明,输入框的样式将不会显示。
以下实例使用两个 input 元素,一个是 text,一个是 password :
<
div
class
=
"
form-group
"
>
<
label
for
=
"
usr
"
>
用户名:
label
>
<
input
type
=
"
text
"
class
=
"
form-control
"
id
=
"
usr
"
>
div
>
<
div
class
=
"
form-group
"
>
<
label
for
=
"
pwd
"
>
密码:
label
>
<
input
type
=
"
password
"
class
=
"
form-control
"
id
=
"
pwd
"
>
div
>
尝试一下 »
以下实例演示了 textarea 的样式。
<
div
class
=
"
form-group
"
>
<
label
for
=
"
comment
"
>
评论:
label
>
<
textarea
class
=
"
form-control
"
rows
=
"
5
"
id
=
"
comment
"
>
textarea
>
div
>
尝试一下 »
复选框用于让用户从一系列预设置的选项中进行选择,可以选一个或多个。
以下实例包含了三个选项。最后一个是禁用的:
<
div
class
=
"
form-check
"
>
<
label
class
=
"
form-check-label
"
>
<
input
type
=
"
checkbox
"
class
=
"
form-check-input
"
value
=
"
"
>
Option 1
label
>
div
>
<
div
class
=
"
form-check
"
>
<
label
class
=
"
form-check-label
"
>
<
input
type
=
"
checkbox
"
class
=
"
form-check-input
"
value
=
"
"
>
Option 2
label
>
div
>
<
div
class
=
"
form-check disabled
"
>
<
label
class
=
"
form-check-label
"
>
<
input
type
=
"
checkbox
"
class
=
"
form-check-input
"
value
=
"
"
disabled
>
Option 3
label
>
div
>
尝试一下 »
使用 .form-check-inline 类可以让选项显示在同一行上:
<
div
class
=
"
form-check form-check-inline
"
>
<
label
class
=
"
form-check-label
"
>
<
input
type
=
"
checkbox
"
class
=
"
form-check-input
"
value
=
"
"
>
Option 1
label
>
div
>
<
div
class
=
"
form-check form-check-inline
"
>
<
label
class
=
"
form-check-label
"
>
<
input
type
=
"
checkbox
"
class
=
"
form-check-input
"
value
=
"
"
>
Option 2
label
>
div
>
<
div
class
=
"
form-check form-check-inline disabled
"
>
<
label
class
=
"
form-check-label
"
>
<
input
type
=
"
checkbox
"
class
=
"
form-check-input
"
value
=
"
"
disabled
>
Option 3
label
>
div
>
尝试一下 »
单选框用于让用户从一系列预设置的选项中进行选择,只能选一个。
以下实例包含了三个选项。最后一个是禁用的:
<
div
class
=
"
radio
"
>
<
label
>
<
input
type
=
"
radio
"
name
=
"
optradio
"
>
Option 1
label
>
div
>
<
div
class
=
"
radio
"
>
<
label
>
<
input
type
=
"
radio
"
name
=
"
optradio
"
>
Option 2
label
>
div
>
<
div
class
=
"
radio disabled
"
>
<
label
>
<
input
type
=
"
radio
"
name
=
"
optradio
"
disabled
>
Option 3
label
>
div
>
尝试一下 »
使用 .radio-inline 类可以让选项显示在同一行上:
<
label
class
=
"
radio-inline
"
>
<
input
type
=
"
radio
"
name
=
"
optradio
"
>
Option 1
label
>
<
label
class
=
"
radio-inline
"
>
<
input
type
=
"
radio
"
name
=
"
optradio
"
>
Option 2
label
>
<
label
class
=
"
radio-inline
"
>
<
input
type
=
"
radio
"
name
=
"
optradio
"
disabled
>
Option 3
label
>
尝试一下 »
当您想让用户从多个选项中进行选择,但是默认情况下只能选择一个选项时,则使用选择框。
以下实例包含了两个下拉菜单:
<
div
class
=
"
form-group
"
>
<
label
for
=
"
sel1
"
>
下拉菜单:
label
>
<
select
class
=
"
form-control
"
id
=
"
sel1
"
>
<
option
>
1
option
>
<
option
>
2
option
>
<
option
>
3
option
>
<
option
>
4
option
>
select
>
div
>
尝试一下 »
网站名称:创新互联Bootstrap4教程:Bootstrap4表单控件
文章网址:http://www.csdahua.cn/qtweb/news7/442807.html
网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 快上网