Hla mus rau cov ntsiab lus tseem ceeb Hla mus rau docs navigation
Check
in English

Spinners

Qhia txog lub xeev thauj khoom ntawm ib feem lossis nplooj ntawv nrog Bootstrap spinners, ua tiav nrog HTML, CSS, thiab tsis muaj JavaScript.

Txog

Bootstrap "spinners" tuaj yeem siv los qhia txog lub xeev thauj khoom hauv koj cov haujlwm. Lawv tsuas yog tsim nrog HTML thiab CSS, txhais tau tias koj tsis tas yuav muaj JavaScript los tsim lawv. Txawm li cas los xij, koj yuav xav tau qee qhov kev cai JavaScript los hloov lawv qhov pom. Lawv cov tsos, sib dhos, thiab qhov loj me tuaj yeem hloov kho tau yooj yim nrog peb cov chav kawm siv hluav taws xob zoo.

Rau kev siv tau yooj yim, txhua lub loader ntawm no suav nrog role="status"thiab ib qho zes <span class="visually-hidden">Loading...</span>.

Cov nyhuv animation ntawm cov khoom no yog nyob ntawm cov prefers-reduced-motionlus nug xov xwm. Saib qhov txo qis ntawm peb cov ntaub ntawv nkag mus tau .

Ciam teb spinner

Siv cov ciam teb spinners rau lub teeb yuag qhov taw qhia.

Loading...
html
<div class="spinner-border" role="status">
  <span class="visually-hidden">Loading...</span>
</div>

Xim

Tus ciam teb spinner siv currentColorrau nws border-color, txhais tau tias koj tuaj yeem kho cov xim nrog cov ntawv xim siv . Koj tuaj yeem siv ib qho ntawm peb cov ntawv siv xim xim ntawm tus qauv spinner.

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
html
<div class="spinner-border text-primary" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-border text-secondary" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-border text-success" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-border text-danger" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-border text-warning" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-border text-info" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-border text-light" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-border text-dark" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
Vim li cas ho tsis siv cov khoom siv border-colorhluav taws xob? Txhua tus ciam teb spinner qhia txog transparentciam teb tsawg kawg yog ib sab, yog li .border-{color}kev siv hluav taws xob yuav hla dhau qhov ntawd.

Loj hlob spinner

Yog tias koj tsis nyiam tus ciam teb spinner, hloov mus rau qhov loj hlob spinner. Thaum nws tsis technically spin, nws pheej pheej loj hlob!

Loading...
html
<div class="spinner-grow" role="status">
  <span class="visually-hidden">Loading...</span>
</div>

Ib zaug ntxiv, qhov spinner no tau tsim nrog currentColor, yog li koj tuaj yeem hloov nws cov tsos nrog cov ntawv xim xim . Ntawm no nws yog xiav, nrog rau kev txhawb nqa variants.

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
html
<div class="spinner-grow text-primary" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-grow text-secondary" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-grow text-success" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-grow text-danger" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-grow text-warning" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-grow text-info" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-grow text-light" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-grow text-dark" role="status">
  <span class="visually-hidden">Loading...</span>
</div>

Kev sib tw

Spinners hauv Bootstrap yog tsim nrog rems, currentColor, thiab display: inline-flex. Qhov no txhais tau hais tias lawv tuaj yeem hloov pauv tau yooj yim, hloov kho dua tshiab, thiab nrawm nrawm.

Margin

Siv cov khoom siv margin zoo li .m-5kom yooj yim sib nrug.

Loading...
html
<div class="spinner-border m-5" role="status">
  <span class="visually-hidden">Loading...</span>
</div>

Qhov chaw

Siv flexbox utilities , float utilities , lossis text alignment utilities los tso cov spinners raws nraim qhov koj xav tau hauv txhua qhov xwm txheej.

Flex

Loading...
html
<div class="d-flex justify-content-center">
  <div class="spinner-border" role="status">
    <span class="visually-hidden">Loading...</span>
  </div>
</div>
Loading...
html
<div class="d-flex align-items-center">
  <strong>Loading...</strong>
  <div class="spinner-border ms-auto" role="status" aria-hidden="true"></div>
</div>

ntab

Loading...
html
<div class="clearfix">
  <div class="spinner-border float-end" role="status">
    <span class="visually-hidden">Loading...</span>
  </div>
</div>

Text align

Loading...
html
<div class="text-center">
  <div class="spinner-border" role="status">
    <span class="visually-hidden">Loading...</span>
  </div>
</div>

Loj

Ntxiv .spinner-border-smthiab .spinner-grow-smua kom me me spinner uas tuaj yeem siv tau sai hauv lwm cov khoom.

Loading...
Loading...
html
<div class="spinner-border spinner-border-sm" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-grow spinner-grow-sm" role="status">
  <span class="visually-hidden">Loading...</span>
</div>

Los yog, siv kev cai CSS lossis inline styles hloov qhov ntev raws li xav tau.

Loading...
Loading...
html
<div class="spinner-border" style="width: 3rem; height: 3rem;" role="status">
  <span class="visually-hidden">Loading...</span>
</div>
<div class="spinner-grow" style="width: 3rem; height: 3rem;" role="status">
  <span class="visually-hidden">Loading...</span>
</div>

Khawm

Siv cov spinners hauv cov nyees khawm los qhia tias qhov kev txiav txim tam sim no tab tom ua lossis ua qhov chaw. Koj tuaj yeem hloov cov ntawv tawm ntawm lub caij spinner thiab siv khawm ntawv raws li xav tau.

html
<button class="btn btn-primary" type="button" disabled>
  <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
  <span class="visually-hidden">Loading...</span>
</button>
<button class="btn btn-primary" type="button" disabled>
  <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
  Loading...
</button>
html
<button class="btn btn-primary" type="button" disabled>
  <span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
  <span class="visually-hidden">Loading...</span>
</button>
<button class="btn btn-primary" type="button" disabled>
  <span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
  Loading...
</button>

CSS

Hloov pauv

Ntxiv hauv v5.2.0

Raws li ib feem ntawm Bootstrap qhov hloov pauv CSS hloov pauv mus kom ze, spinners tam sim no siv cov CSS hauv zos sib txawv ntawm .spinner-borderthiab .spinner-growrau kev hloov kho lub sijhawm tiag tiag. Cov txiaj ntsig rau CSS qhov sib txawv tau teeb tsa ntawm Sass, yog li Sass customization tseem txhawb nqa, ib yam nkaus.

Ciam teb spinner variables:

  --#{$prefix}spinner-width: #{$spinner-width};
  --#{$prefix}spinner-height: #{$spinner-height};
  --#{$prefix}spinner-vertical-align: #{$spinner-vertical-align};
  --#{$prefix}spinner-border-width: #{$spinner-border-width};
  --#{$prefix}spinner-animation-speed: #{$spinner-animation-speed};
  --#{$prefix}spinner-animation-name: spinner-border;
  

Loj hlob spinner variables:

  --#{$prefix}spinner-width: #{$spinner-width};
  --#{$prefix}spinner-height: #{$spinner-height};
  --#{$prefix}spinner-vertical-align: #{$spinner-vertical-align};
  --#{$prefix}spinner-animation-speed: #{$spinner-animation-speed};
  --#{$prefix}spinner-animation-name: spinner-grow;
  

Rau ob qho tib si spinners, cov chav kawm me me spinner hloov kho yog siv los hloov kho cov txiaj ntsig ntawm cov CSS hloov pauv raws li xav tau. Piv txwv li, .spinner-border-smchav kawm ua cov hauv qab no:

  --#{$prefix}spinner-width: #{$spinner-width-sm};
  --#{$prefix}spinner-height: #{$spinner-height-sm};
  --#{$prefix}spinner-border-width: #{$spinner-border-width-sm};
  

Sass variables

$spinner-width:           2rem;
$spinner-height:          $spinner-width;
$spinner-vertical-align:  -.125em;
$spinner-border-width:    .25em;
$spinner-animation-speed: .75s;

$spinner-width-sm:        1rem;
$spinner-height-sm:       $spinner-width-sm;
$spinner-border-width-sm: .2em;

Keyframes

Siv los tsim cov CSS animations rau peb spinners. suav nrog scss/_spinners.scss.

@keyframes spinner-border {
  to { transform: rotate(360deg) #{"/* rtl:ignore */"}; }
}
@keyframes spinner-grow {
  0% {
    transform: scale(0);
  }
  50% {
    opacity: 1;
    transform: none;
  }
}