Yeqela kokuqukethwe okuyinhloko Yeqela ku-docs navigation
Check
in English

Amaspinner

Bonisa isimo sokulayisha sengxenye noma ikhasi elinamaspinner e-Bootstrap, elakhiwe ngokuphelele nge-HTML, CSS, futhi ayikho i-JavaScript.

Mayelana

I-Bootstrap “spinners” ingasetshenziswa ukukhombisa isimo sokulayisha kumaphrojekthi akho. Akhiwe kuphela nge-HTML ne-CSS, okusho ukuthi awudingi i-JavaScript ukuze uwadale. Nokho, uzodinga i-JavaScript yangokwezifiso ukuze uguqule ukubonakala kwayo. Ukubukeka kwabo, ukuqondanisa, kanye nosayizi kungenziwa ngendlela oyifisayo kalula ngamakilasi ethu amangalisayo awusizo.

Ngezinjongo zokufinyelela, isilayishi ngasinye lapha sihlanganisa role="status"kanye nesidleke <span class="visually-hidden">Loading...</span>.

Umthelela wokugqwayiza wale ngxenye uncike prefers-reduced-motionembuzweni wemidiya. Bona ingxenye yokunyakaza encishisiwe yemibhalo yethu yokufinyeleleka .

Isipina somngcele

Sebenzisa ama-spinner omngcele ukuze uthole inkomba yokulayisha engasindi.

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

Imibala

Isipina somngcele sisebenzisela currentColorsona border-color, okusho ukuthi ungakwazi ukwenza ngokwezifiso umbala ngezinsiza zombala wombhalo . Ungasebenzisa noma yiziphi izinsiza zethu zombala wombhalo kusipina esijwayelekile.

Iyalayisha...
Iyalayisha...
Iyalayisha...
Iyalayisha...
Iyalayisha...
Iyalayisha...
Iyalayisha...
Iyalayisha...
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>
Kungani ungasebenzisi border-colorizinsiza? Isipina somngcele ngasinye sicacisa transparentumngcele okungenani ohlangothini olulodwa, ngakho .border-{color}izinsiza zingakweqa lokho.

I-spinner ekhulayo

Uma ungasithandisisi isipina somngcele, shintshela kusipina sokukhula. Nakuba ingaphenduki ngokobuchwepheshe, ikhula ngokuphindaphindiwe!

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

Nakulokhu futhi, lesi sipina sakhiwe nge- currentColor, ngakho-ke ungakwazi ukushintsha kalula ukubukeka kwaso ngezinsiza zombala wombhalo . Nansi iluhlaza okwesibhakabhaka, kanye nezinhlobonhlobo ezisekelwayo.

Iyalayisha...
Iyalayisha...
Iyalayisha...
Iyalayisha...
Iyalayisha...
Iyalayisha...
Iyalayisha...
Iyalayisha...
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>

Ukuqondanisa

Izipina ku-Bootstrap zakhiwe ngo- rems, currentColor, kanye display: inline-flex. Lokhu kusho ukuthi zingashintshwa kalula, zifakwe umbala kabusha, futhi ziqondaniswe ngokushesha.

Imajini

Sebenzisa izinsiza ze-margin njengokwenza .m-5isikhala kalula.

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

Ukubekwa

Sebenzisa izinsiza ze-flexbox , izinsiza ze- float , noma izinsiza zokuqondanisa umbhalo ukuze ubeke izipina lapho uzidinga khona kunoma yisiphi isimo.

I-Flex

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

Iyantanta

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

Qondanisa umbhalo

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

Usayizi

Engeza .spinner-border-smfuthi .spinner-grow-smwenze isipina esincane esingasetshenziswa ngokushesha kwezinye izingxenye.

Iyalayisha...
Iyalayisha...
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>

Noma, sebenzisa i-CSS yangokwezifiso noma izitayela ezisemgqeni ukuze uguqule ubukhulu njengoba kudingeka.

Iyalayisha...
Iyalayisha...
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>

Izinkinobho

Sebenzisa ama-spinner ngaphakathi kwezinkinobho ukuze ubonise ukuthi isenzo okwamanje siyacutshungulwa noma senzekayo. Ungakwazi futhi ukushintsha umbhalo uphume entweni yesipina futhi usebenzise umbhalo wenkinobho njengoba kudingeka.

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

Okuguquguqukayo

Kwengezwe ku-v5.2.0

Njengengxenye yendlela yokuguquguquka kwe-CSS ye-Bootstrap, ama-spinner manje asebenzisa okuguquguqukayo kwasendaweni kwe-CSS .spinner-borderukuze .spinner-growathuthukise ukwenza ngokwezifiso isikhathi sangempela. Amanani okuguquguquka kwe-CSS asethwa nge-Sass, ngakho ukwenza ngokwezifiso kwe-Sass kusasekelwa, nakho.

Okuguquguqukayo kwe-border spinner:

  --#{$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;
  

Ukukhula okuguquguqukayo kwesipina:

  --#{$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;
  

Kuwo womabili ama-spinner, amakilasi amancane okuguqula isipina asetshenziselwa ukubuyekeza amanani alezi ziguquko ze-CSS njengoba kudingeka. Isibonelo, .spinner-border-smikilasi lenza lokhu okulandelayo:

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

Izinguquko ze-Sass

$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;

Ozimele abangukhiye

Isetshenziselwa ukudala izithombe ze-CSS zama-spinner ethu. Kufakwe ku scss/_spinners.scss.

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