Rach gu prìomh shusbaint Air adhart gu seòladh docs
Check
in English

Adhartas

Sgrìobhainnean agus eisimpleirean airson a bhith a’ cleachdadh bhàraichean adhartais àbhaisteach Bootstrap le taic airson bàraichean air an càrnadh, cùl-raointean beòthail, agus bileagan teacsa.

Mar a tha e ag obair

Tha co-phàirtean adhartais air an togail le dà eileamaid HTML, cuid de CSS gus an leud a shuidheachadh, agus beagan fheartan. Cha bhith sinn a’ cleachdadh an eileamaid HTML5<progress> , a’ dèanamh cinnteach gun urrainn dhut bàraichean adhartais a chruachadh, am beothachadh, agus bileagan teacsa a chuir thairis orra.

  • Bidh sinn a’ cleachdadh an .progressmar phasgan gus an luach as motha den bhàr adhartais a chomharrachadh.
  • Cleachdaidh sinn an taobh a-staigh .progress-bargus an adhartas gu ruige seo a chomharrachadh.
  • Tha .progress-barfeum air stoidhle in-loidhne, clas goireis, no CSS àbhaisteach gus an leud a shuidheachadh.
  • Tha .progress-barfeum cuideachd air cuid roleagus ariabuadhan gus a dhèanamh ruigsinneach, a’ toirt a-steach ainm ruigsinneach (a’ cleachdadh aria-label, aria-labelledby, no a leithid).

Cuir sin uile ri chèile, agus tha na h-eisimpleirean a leanas agad.

html
<div class="progress">
  <div class="progress-bar" role="progressbar" aria-label="Basic example" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress">
  <div class="progress-bar" role="progressbar" aria-label="Basic example" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress">
  <div class="progress-bar" role="progressbar" aria-label="Basic example" style="width: 50%" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress">
  <div class="progress-bar" role="progressbar" aria-label="Basic example" style="width: 75%" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress">
  <div class="progress-bar" role="progressbar" aria-label="Basic example" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
</div>

Bidh Bootstrap a’ toirt seachad dòrlach de ghoireasan airson leud a shuidheachadh . A rèir do fheumalachdan, dh’ fhaodadh iad sin cuideachadh le bhith a’ rèiteachadh adhartas gu sgiobalta.

html
<div class="progress">
  <div class="progress-bar w-75" role="progressbar" aria-label="Basic example" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
</div>

Bileagan

Cuir bileagan ris na bàraichean adhartais agad le bhith a’ cur teacsa taobh a-staigh an fhaidhle .progress-bar.

25%
html
<div class="progress">
  <div class="progress-bar" role="progressbar" aria-label="Example with label" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">25%</div>
</div>

Àirde

Cha chuir sinn ach heightluach air an .progress, mar sin ma dh'atharraicheas tu an luach sin thèid an taobh a-staigh .progress-barath-mheudachadh gu fèin-obrachail a rèir sin.

html
<div class="progress" style="height: 1px;">
  <div class="progress-bar" role="progressbar" aria-label="Example 1px high" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress" style="height: 20px;">
  <div class="progress-bar" role="progressbar" aria-label="Example 20px high" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>

Cùl-fhiosrachadh

Cleachd clasaichean cùl-fhiosrachaidh gus coltas bhàraichean adhartais fa leth atharrachadh.

html
<div class="progress">
  <div class="progress-bar bg-success" role="progressbar" aria-label="Success example" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress">
  <div class="progress-bar bg-info" role="progressbar" aria-label="Info example" style="width: 50%" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress">
  <div class="progress-bar bg-warning" role="progressbar" aria-label="Warning example" style="width: 75%" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress">
  <div class="progress-bar bg-danger" role="progressbar" aria-label="Danger example" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
</div>
A’ toirt brìgh do theicneòlasan cuideachail

Chan eil a bhith a’ cleachdadh dath gus brìgh a chur ris ach a’ toirt seachad sealladh lèirsinneach, nach tèid a thoirt do luchd-cleachdaidh theicneòlasan taice - leithid leughadairean sgrion. Dèan cinnteach gu bheil fiosrachadh air a chomharrachadh leis an dath an dàrna cuid follaiseach bhon t-susbaint fhèin (me an teacsa faicsinneach), no air a thoirt a-steach tro dhòighean eile, leithid teacsa a bharrachd falaichte leis a’ .visually-hiddenchlas.

Ioma bàraichean

Cuir a-steach grunn bhàraichean adhartais ann am pàirt adhartais ma tha feum agad air.

html
<div class="progress">
  <div class="progress-bar" role="progressbar" aria-label="Segment one" style="width: 15%" aria-valuenow="15" aria-valuemin="0" aria-valuemax="100"></div>
  <div class="progress-bar bg-success" role="progressbar" aria-label="Segment two" style="width: 30%" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100"></div>
  <div class="progress-bar bg-info" role="progressbar" aria-label="Segment three" style="width: 20%" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"></div>
</div>

Air a stialladh

Cuir .progress-bar-stripedri fear sam bith .progress-bargus stripe a chuir an sàs tro chaise CSS thairis air dath cùl a’ bhàr adhartais.

html
<div class="progress">
  <div class="progress-bar progress-bar-striped" role="progressbar" aria-label="Default striped example" style="width: 10%" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress">
  <div class="progress-bar progress-bar-striped bg-success" role="progressbar" aria-label="Success striped example" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress">
  <div class="progress-bar progress-bar-striped bg-info" role="progressbar" aria-label="Info striped example" style="width: 50%" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress">
  <div class="progress-bar progress-bar-striped bg-warning" role="progressbar" aria-label="Warning striped example" style="width: 75%" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress">
  <div class="progress-bar progress-bar-striped bg-danger" role="progressbar" aria-label="Danger striped example" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
</div>

Stripes beòthail

Faodar an caisead stiallach a bheothachadh cuideachd. Cuir .progress-bar-animatedris .progress-bargus na stiallan a bheothachadh deas gu clì tro bheòthachaidhean CSS3.

html
<div class="progress">
  <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-label="Animated striped example" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%"></div>
</div>

CSS

Caochlaidhean

Air a chur ris ann an v5.2.0

Mar phàirt de dhòigh-obrach caochladairean CSS Bootstrap, tha bàraichean adhartais a-nis a’ cleachdadh caochladairean CSS ionadail .progressairson gnàthachadh fìor-ùine leasaichte. Tha luachan airson caochladairean CSS air an suidheachadh tro Sass, agus mar sin tha gnàthachadh Sass fhathast a’ faighinn taic, cuideachd.

  --#{$prefix}progress-height: #{$progress-height};
  @include rfs($progress-font-size, --#{$prefix}progress-font-size);
  --#{$prefix}progress-bg: #{$progress-bg};
  --#{$prefix}progress-border-radius: #{$progress-border-radius};
  --#{$prefix}progress-box-shadow: #{$progress-box-shadow};
  --#{$prefix}progress-bar-color: #{$progress-bar-color};
  --#{$prefix}progress-bar-bg: #{$progress-bar-bg};
  --#{$prefix}progress-bar-transition: #{$progress-bar-transition};
  

caochladairean Sass

$progress-height:                   1rem;
$progress-font-size:                $font-size-base * .75;
$progress-bg:                       $gray-200;
$progress-border-radius:            $border-radius;
$progress-box-shadow:               $box-shadow-inset;
$progress-bar-color:                $white;
$progress-bar-bg:                   $primary;
$progress-bar-animation-timing:     1s linear infinite;
$progress-bar-transition:           width .6s ease;

Keyframes

Air a chleachdadh airson beòthachaidhean CSS a chruthachadh airson .progress-bar-animated. Air a ghabhail a-steach ann an scss/_progress-bar.scss.

@if $enable-transitions {
  @keyframes progress-bar-stripes {
    0% { background-position-x: $progress-height; }
  }
}