默认情况下,标签内容一般显示在 input 输入框的上方:
使用浮动标签,可以在 input 输入框内插入标签,在单击 input 输入框时使它们浮动到上方
<
div
class
=
"
form-floating mb-3 mt-3
"
>
<
input
type
=
"
text
"
class
=
"
form-control
"
id
=
"
email
"
placeholder
=
"
Enter email
"
name
=
"
email
"
>
<
label
for
=
"
email
"
>
Email
label
>
div
>
<
div
class
=
"
form-floating mt-3 mb-3
"
>
<
input
type
=
"
text
"
class
=
"
form-control
"
id
=
"
pwd
"
placeholder
=
"
Enter password
"
name
=
"
pswd
"
>
<
label
for
=
"
pwd
"
>
Password
label
>
div
>
尝试一下 »
注意事项:
文本框 textarea 也可以有浮动效果:
<
div
class
=
"
form-floating
"
>
<
textarea
class
=
"
form-control
"
id
=
"
comment
"
name
=
"
text
"
placeholder
=
"
Comment goes here
"
>
textarea
>
<
label
for
=
"
comment
"
>
Comments
label
>
div
>
尝试一下 »
我们可以在选择菜单上使用浮动标签,它将始终显示在选择菜单的左上角,不会有点击浮动效果:
<
div
class
=
"
form-floating
"
>
<
select
class
=
"
form-select
"
id
=
"
sel1
"
name
=
"
sellist
"
>
<
option
>
1
option
>
<
option
>
2
option
>
<
option
>
3
option
>
<
option
>
4
option
>
select
>
<
label
for
=
"
sel1
"
class
=
"
form-label
"
>
Select list (select one):
label
>
div
>
尝试一下 »
网站名称:创新互联Bootstrap5教程:Bootstrap5表单浮动标签
当前路径:http://www.csdahua.cn/qtweb/news17/325467.html
网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 快上网