Vim muaj kev siv ntau ntawm <table>cov ntsiab lus thoob plaws peb-tog widgets xws li daim ntawv qhia hnub thiab cov hnub xaiv, Bootstrap cov ntxhuav yog xaiv . Ntxiv cov chav kawm hauv paus .tablerau ib qho twg <table>, tom qab ntawd txuas ntxiv nrog peb cov kev xaiv hloov kho cov chav kawm lossis cov qauv kev cai. Tag nrho cov rooj style tsis tau txais txiaj ntsig hauv Bootstrap, txhais tau tias txhua lub rooj sib tham tuaj yeem tsim los ntawm niam txiv.
Siv cov lus qhia yooj yim tshaj plaws, ntawm no yog li cas .table-raws li cov ntxhuav saib hauv Bootstrap.
#
Ua ntej
Kawg
tuav
1
Mark
Otto
@mdo
2
Yakhauj
Thornton
@fat
3
Larry noog
@twitter
<tableclass="table"><thead><tr><thscope="col">#</th><thscope="col">First</th><thscope="col">Last</th><thscope="col">Handle</th></tr></thead><tbody><tr><thscope="row">1</th><td>Mark</td><td>Otto</td><td>@mdo</td></tr><tr><thscope="row">2</th><td>Jacob</td><td>Thornton</td><td>@fat</td></tr><tr><thscope="row">3</th><tdcolspan="2">Larry the Bird</td><td>@twitter</td></tr></tbody></table>
Variants
Siv cov chav kawm contextual rau xim cov ntxhuav, kab kab los yog ib lub hlwb.
Chav kawm
Lub taub hau
Lub taub hau
Default
Cell
Cell
Thawj
Cell
Cell
Secondary
Cell
Cell
Kev vam meej
Cell
Cell
Kev phom sij
Cell
Cell
Ceeb toom
Cell
Cell
Cov ntaub ntawv
Cell
Cell
Teeb
Cell
Cell
Tsaus
Cell
Cell
<!-- On tables --><tableclass="table-primary">...</table><tableclass="table-secondary">...</table><tableclass="table-success">...</table><tableclass="table-danger">...</table><tableclass="table-warning">...</table><tableclass="table-info">...</table><tableclass="table-light">...</table><tableclass="table-dark">...</table><!-- On rows --><trclass="table-primary">...</tr><trclass="table-secondary">...</tr><trclass="table-success">...</tr><trclass="table-danger">...</tr><trclass="table-warning">...</tr><trclass="table-info">...</tr><trclass="table-light">...</tr><trclass="table-dark">...</tr><!-- On cells (`td` or `th`) --><tr><tdclass="table-primary">...</td><tdclass="table-secondary">...</td><tdclass="table-success">...</td><tdclass="table-danger">...</td><tdclass="table-warning">...</td><tdclass="table-info">...</td><tdclass="table-light">...</td><tdclass="table-dark">...</td></tr>
Qhia lub ntsiab lus rau kev pab technologies
Siv cov xim los ntxiv cov ntsiab lus tsuas yog muab qhov pom kev pom, uas yuav tsis raug xa mus rau cov neeg siv cov thev naus laus zis pab - xws li cov ntawv nyeem. Xyuas kom meej tias cov ntaub ntawv qhia los ntawm cov xim yog pom tseeb los ntawm cov ntsiab lus nws tus kheej (xws li cov ntawv pom), lossis suav nrog lwm txoj kev, xws li cov ntawv ntxiv zais nrog cov .visually-hiddenchav kawm.
Peb pib los ntawm kev teeb tsa keeb kwm yav dhau ntawm lub rooj ntawm tes nrog cov --bs-table-bgcuab yeej kev cai. Tag nrho cov rooj variants ces teeb tsa cov cuab yeej kev cai ntawd los ua kom cov xim ntawm lub rooj. Txoj kev no, peb tsis muaj teeb meem yog tias cov xim semi-pob tshab yog siv los ua cov ntawv keeb kwm yav dhau los.
Tom qab ntawd peb ntxiv ib lub thawv duab ntxoov ntxoo rau ntawm lub rooj cell nrog box-shadow: inset 0 0 0 9999px var(--bs-table-accent-bg);rau txheej saum toj ntawm txhua qhov teev background-color. Vim tias peb siv qhov sib kis loj thiab tsis muaj qhov muag plooj, xim yuav yog monotone. Txij li thaum --bs-table-accent-bgtsis tau teeb tsa los ntawm lub neej ntawd, peb tsis muaj lub thawv duab ntxoov ntxoo.
Thaum twg los xij .table-striped, .table-hoverlossis .table-activecov chav kawm ntxiv, qhov --bs-table-accent-bgyog teem rau ib nrab pob tshab xim rau xim tom qab.
Cov kab lus ntawm <thead>ib txwm ntsug mus rau hauv qab. Cov kab lus hauv <tbody>cov khoom qub txeeg qub teg ntawm lawv cov kev sib raug zoo los ntawm <table>thiab tau ua raws li cov lus saum toj kawg nkaus. Siv cov chav kawm ntsug dlhos kom rov ua raws li qhov xav tau.
Ntsiab lus 1
Ntsiab lus 2
Ntsiab lus 3
Ntsiab lus 4
Cov cell no tau txais vertical-align: middle;los ntawm lub rooj
Cov cell no tau txais vertical-align: middle;los ntawm lub rooj
Cov cell no tau txais vertical-align: middle;los ntawm lub rooj
Qhov no ntawm no yog ib co placeholder ntawv nyeem, npaj yuav coj mus rau ib tug heev me ntsis ntawm ntsug qhov chaw, qhia tau hais tias yuav ua li cas cov ntsug dlhos ua hauj lwm nyob rau hauv lub hlwb ua ntej.
Cov cell no tau txais vertical-align: bottom;los ntawm kab lus
Cov cell no tau txais vertical-align: bottom;los ntawm kab lus
Cov cell no tau txais vertical-align: bottom;los ntawm kab lus
Qhov no ntawm no yog ib co placeholder ntawv nyeem, npaj yuav coj mus rau ib tug heev me ntsis ntawm ntsug qhov chaw, qhia tau hais tias yuav ua li cas cov ntsug dlhos ua hauj lwm nyob rau hauv lub hlwb ua ntej.
Cov cell no tau txais vertical-align: middle;los ntawm lub rooj
Cov cell no tau txais vertical-align: middle;los ntawm lub rooj
Lub xovtooj ntawm no yog ua raws li cov lus saum toj kawg nkaus.
Qhov no ntawm no yog ib co placeholder ntawv nyeem, npaj yuav coj mus rau ib tug heev me ntsis ntawm ntsug qhov chaw, qhia tau hais tias yuav ua li cas cov ntsug dlhos ua hauj lwm nyob rau hauv lub hlwb ua ntej.
<divclass="table-responsive"><tableclass="table align-middle"><thead><tr>
...
</tr></thead><tbody><tr>
...
</tr><trclass="align-bottom">
...
</tr><tr><td>...</td><td>...</td><tdclass="align-top">This cell is aligned to the top.</td><td>...</td></tr></tbody></table></div>
Zes
Cov qauv ciam teb, cov qauv nquag, thiab cov rooj sib txawv tsis tau txais los ntawm cov rooj nested.
Txhawm rau tiv thaiv txhua tus qauv los ntawm kev xau mus rau cov rooj zes, peb siv tus menyuam sib txuas ( >) xaiv hauv peb CSS. Txij li thaum peb xav tau lub hom phiaj tag nrho cov tds thiab ths nyob rau hauv lub thead, tbody, thiab tfoot, peb selector yuav saib zoo nkauj ntev yam tsis muaj nws. Yog li ntawd, peb siv qhov txawv txawv saib .table > :not(caption) > * > *xaiv los tsom tag nrho tdcov s thiab ths ntawm cov .table, tab sis tsis muaj ib qho ntawm cov rooj zaum nested.
Nco ntsoov tias yog tias koj ntxiv <tr>s raws li cov menyuam yaus ntawm lub rooj, cov <tr>no yuav raug muab qhwv rau hauv lub <tbody>neej ntawd, yog li ua rau peb cov neeg xaiv ua haujlwm raws li qhov xav tau.
Anatomy
Lub taub hau
Zoo ib yam li cov ntxhuav thiab cov ntxhuav tsaus, siv cov chav kawm hloov kho .table-lightlossis .table-darkua kom <thead>pom lub teeb lossis tsaus grey.
<tableclass="table caption-top"><caption>List of users</caption><thead><tr><thscope="col">#</th><thscope="col">First</th><thscope="col">Last</th><thscope="col">Handle</th></tr></thead><tbody><tr><thscope="row">1</th><td>Mark</td><td>Otto</td><td>@mdo</td></tr><tr><thscope="row">2</th><td>Jacob</td><td>Thornton</td><td>@fat</td></tr><tr><thscope="row">3</th><td>Larry</td><td>the Bird</td><td>@twitter</td></tr></tbody></table>
Cov lus teb
Responsive tables tso cai rau cov ntxhuav tau scrolled horizontally yooj yim. Ua ib lub rooj teb thoob plaws txhua qhov chaw saib los ntawm kev qhwv ib qho .tablenrog .table-responsive. Los yog, xaiv qhov siab tshaj plaws breakpoint uas yuav tsum muaj cov lus teb los ntawm kev siv .table-responsive{-sm|-md|-lg|-xl|-xxl}.
Vertical clipping/truncation
Cov lus teb ua rau siv overflow-y: hidden, uas clips tawm cov ntsiab lus uas dhau mus rau hauv qab lossis sab saum toj ntawm lub rooj. Tshwj xeeb, qhov no tuaj yeem txiav tawm cov ntawv qhia zaub mov thiab lwm tus neeg thib peb widgets.
Siv .table-responsive{-sm|-md|-lg|-xl|-xxl}raws li xav tau los tsim cov lus teb mus txog rau ib qho kev tawg. Los ntawm qhov tawg thiab nce mus, lub rooj yuav coj li ib txwm thiab tsis scroll horizontally.
Cov rooj no yuav tshwm sim tawg kom txog thaum lawv cov qauv teb siv tau ntawm qhov dav dav dav dav.