Ntau yam
Siv peb cov kev cai ntau yam inputs rau qhov sib npaug ntawm qhov browser styling thiab built-in customization.
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.
<label for="customRange1" class="form-label">Example range</label>
<input type="range" class="form-range" id="customRange1">
Neeg tsis taus
Ntxiv tus disabled
cwj pwm boolean ntawm ib qho kev tawm tswv yim kom muab nws lub ntsej muag greyed thiab tshem tawm cov xwm txheej pointer.
<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 min
thiab max
— 0
thiab 100
, feem. Koj tuaj yeem qhia qhov tseem ceeb tshiab rau cov uas siv cov khoom min
thiab max
cov cwj pwm.
<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 step
nqi. Hauv qhov piv txwv hauv qab no, peb muab ob npaug ntawm cov kauj ruam los ntawm kev siv step="0.5"
.
<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;