新聞中心
Bootstrap5 輸入框組
我們可以使用 .input-group 類來向表單輸入框中添加更多的樣式,如圖標、文本或者按鈕。

你所需要的網(wǎng)站建設(shè)服務(wù),我們均能行業(yè)靠前的水平為你提供.標準是產(chǎn)品質(zhì)量的保證,主要從事網(wǎng)站制作、成都網(wǎng)站制作、企業(yè)網(wǎng)站建設(shè)、手機網(wǎng)站制作設(shè)計、網(wǎng)頁設(shè)計、品牌網(wǎng)站建設(shè)、網(wǎng)頁制作、做網(wǎng)站、建網(wǎng)站。成都創(chuàng)新互聯(lián)公司擁有實力堅強的技術(shù)研發(fā)團隊及素養(yǎng)的視覺設(shè)計專才。
.input-group-text 類來設(shè)置文本的樣式。
Bootstrap 實例
<
form
>
<
div
class
=
"
input-group mb-3
"
>
<
span
class
=
"
input-group-text
"
>
@
span
>
<
input
type
=
"
text
"
class
=
"
form-control
"
placeholder
=
"
Username
"
>
div
>
<
div
class
=
"
input-group
"
>
<
input
type
=
"
text
"
class
=
"
form-control
"
placeholder
=
"
Your Email
"
>
<
span
class
=
"
input-group-text
"
>
@cdcxhl.com
span
>
div
>
form
>
嘗試一下 ?
輸入框大小
使用 .input-group-sm 類來設(shè)置小的輸入框, .input-group-lg 類設(shè)置大的輸入框:
Bootstrap 實例
<
div
class
=
"
input-group mb-3 input-group-sm
"
>
<
span
class
=
"
input-group-text
"
>
Small
span
>
<
input
type
=
"
text
"
class
=
"
form-control
"
>
div
>
<
div
class
=
"
input-group mb-3
"
>
<
span
class
=
"
input-group-text
"
>
Default
span
>
<
input
type
=
"
text
"
class
=
"
form-control
"
>
>
div
>
<
div
class
=
"
input-group mb-3 input-group-lg
"
>
<
span
class
=
"
input-group-text
"
>
Large
span
>
<
input
type
=
"
text
"
class
=
"
form-control
"
>
div
>
嘗試一下 ?
多個輸入框和文本
Bootstrap 實例
<
div
class
=
"
input-group mb-3
"
>
<
span
class
=
"
input-group-text
"
>
Person
span
>
<
input
type
=
"
text
"
class
=
"
form-control
"
placeholder
=
"
First Name
"
>
<
input
type
=
"
text
"
class
=
"
form-control
"
placeholder
=
"
Last Name
"
>
div
>
<
div
class
=
"
input-group mb-3
"
>
<
span
class
=
"
input-group-text
"
>
One
span
>
<
span
class
=
"
input-group-text
"
>
Two
span
>
<
span
class
=
"
input-group-text
"
>
Three
span
>
<
input
type
=
"
text
"
class
=
"
form-control
"
>
div
>
嘗試一下 ?
復(fù)選框與單選框
文本信息可以使用復(fù)選框與單選框替代:
Bootstrap 實例
<
div
class
=
"
input-group mb-3
"
>
<
div
class
=
"
input-group-text
"
>
<
input
type
=
"
checkbox
"
>
div
>
<
input
type
=
"
text
"
class
=
"
form-control
"
placeholder
=
"
RUNOOB
"
>
div
>
<
div
class
=
"
input-group mb-3
"
>
<
div
class
=
"
input-group-text
"
>
<
input
type
=
"
radio
"
>
div
>
<
input
type
=
"
text
"
class
=
"
form-control
"
placeholder
=
"
GOOGLE
"
>
div
>
嘗試一下 ?
輸入框添加按鈕組
Bootstrap 實例
<
div
class
=
"
input-group mb-3
"
>
<
button
class
=
"
btn btn-outline-primary
"
type
=
"
button
"
>
Basic Button
button
>
<
input
type
=
"
text
"
class
=
"
form-control
"
placeholder
=
"
Some text
"
>
div
>
<
div
class
=
"
input-group mb-3
"
>
<
input
type
=
"
text
"
class
=
"
form-control
"
placeholder
=
"
Search
"
>
<
button
class
=
"
btn btn-success
"
type
=
"
submit
"
>
Go
button
>
div
>
<
div
class
=
"
input-group mb-3
"
>
<
input
type
=
"
text
"
class
=
"
form-control
"
placeholder
=
"
Something clever..
"
>
<
button
class
=
"
btn btn-primary
"
type
=
"
button
"
>
OK
button
>
<
button
class
=
"
btn btn-danger
"
type
=
"
button
"
>
Cancel
button
>
div
>
嘗試一下 ?
設(shè)置下拉菜單
輸入框中添加下拉菜單不需要使用 .dropdown 類。
Bootstrap 實例
<
div
class
=
"
input-group mt-3 mb-3
"
>
<
button
type
=
"
button
"
class
=
"
btn btn-primary dropdown-toggle
"
data-bs-toggle
=
"
dropdown
"
>
選擇網(wǎng)站
button
>
<
ul
class
=
"
dropdown-menu
"
>
<
li
>
<
a
class
=
"
dropdown-item
"
href
=
"
https://www.google.com
"
>
GOOGLE
a
>
li
>
<
li
>
<
a
class
=
"
dropdown-item
"
href
=
"
https://www.cdcxhl.com
"
>
RUNOOB
a
>
li
>
<
li
>
<
a
class
=
"
dropdown-item
"
href
=
"
https://www.taobao.com
"
>
TAOBAO
a
>
li
>
ul
>
<
input
type
=
"
text
"
class
=
"
form-control
"
placeholder
=
"
網(wǎng)站地址
"
>
div
>
嘗試一下 ?
輸入框組標簽
在輸入框組通過在輸入框組外圍的 label 來設(shè)置標簽,標簽的 for 屬性需要與輸入框組的 id 對應(yīng),點擊標簽后可以聚焦輸入框:
Bootstrap 實例
<
form
>
<
label
for
=
"
demo
"
>
這里輸入您的郵箱:
label
>
<
div
class
=
"
input-group mb-3
"
>
<
input
type
=
"
text
"
class
=
"
form-control
"
placeholder
=
"
Email
"
id
=
"
demo
"
name
=
"
email
"
>
<
span
class
=
"
input-group-text
"
>
@cdcxhl.com
span
>
div
>
form
>
嘗試一下 ?
名稱欄目:創(chuàng)新互聯(lián)Bootstrap5教程:Bootstrap5輸入框組
當前鏈接:http://www.dlmjj.cn/article/dhigidh.html


咨詢
建站咨詢
