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

Ntau yam

Siv peb cov kev cai ntau yam inputs rau qhov sib npaug ntawm qhov browser styling thiab built-in customization.

Ntawm nplooj ntawv no

Txheej txheem cej luam

Tsim kev cai <input type="range">tswj nrog .form-range. Cov khiav (tom qab) thiab tus ntiv tes xoo (tus nqi) yog ob qho tib si styled kom tshwm ib yam thoob plaws browsers. Raws li tsuas yog Firefox txhawb nqa "sau" lawv txoj kev los ntawm sab laug lossis sab xis ntawm tus ntiv tes xoo ua ib qho txhais tau tias pom kev nce qib, peb tsis tau txhawb nqa tam sim no.

html
<label for="customRange1" class="form-label">Example range</label>
<input type="range" class="form-range" id="customRange1">

Neeg tsis taus

Ntxiv tus disabledcwj pwm boolean ntawm ib qho kev tawm tswv yim kom muab nws lub ntsej muag greyed, tshem tawm cov xwm txheej pointer, thiab tiv thaiv kev tsom.

html
<label for="disabledRange" class="form-label">Disabled range</label>
<input type="range" class="form-range" id="disabledRange" disabled>

Min thiab max

Ntau yam inputs muaj implicit qhov tseem ceeb rau minthiab max0thiab 100, feem. Koj tuaj yeem qhia qhov tseem ceeb tshiab rau cov uas siv cov khoom minthiab maxcov cwj pwm.

html
<label for="customRange2" class="form-label">Example range</label>
<input type="range" class="form-range" min="0" max="5" id="customRange2">

Cov kauj ruam

Los ntawm lub neej ntawd, ntau yam inputs "snap" rau cov lej suav. Txhawm rau hloov qhov no, koj tuaj yeem qhia tus stepnqi. Hauv qhov piv txwv hauv qab no, peb muab ob npaug ntawm cov kauj ruam los ntawm kev siv step="0.5".

html
<label for="customRange3" class="form-label">Example range</label>
<input type="range" class="form-range" min="0" max="5" step="0.5" id="customRange3">

Sass

Hloov pauv

$form-range-track-width:          100%;
$form-range-track-height:         .5rem;
$form-range-track-cursor:         pointer;
$form-range-track-bg:             $gray-300;
$form-range-track-border-radius:  1rem;
$form-range-track-box-shadow:     $box-shadow-inset;

$form-range-thumb-width:                   1rem;
$form-range-thumb-height:                  $form-range-thumb-width;
$form-range-thumb-bg:                      $component-active-bg;
$form-range-thumb-border:                  0;
$form-range-thumb-border-radius:           1rem;
$form-range-thumb-box-shadow:              0 .1rem .25rem rgba($black, .1);
$form-range-thumb-focus-box-shadow:        0 0 0 1px $body-bg, $input-focus-box-shadow;
$form-range-thumb-focus-box-shadow-width:  $input-focus-width; // For focus box shadow issue in Edge
$form-range-thumb-active-bg:               tint-color($component-active-bg, 70%);
$form-range-thumb-disabled-bg:             $gray-500;
$form-range-thumb-transition:              background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;