要設(shè)置一個(gè)選擇區(qū)間可以在 input 元素中添加 type="range" 并使用 .form-range 類:
選擇區(qū)間:
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap5 實(shí)例</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="stylesheet">
<script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js" rel="external nofollow" rel="external nofollow" rel="external nofollow" ></script>
</head>
<body>
<div class="container mt-3">
<h2>選擇區(qū)間</h2>
<p>要設(shè)置一個(gè)選擇區(qū)間可以在 input 元素中添加 type="range" 并使用 .form-range 類:</p>
<form action="/action_page.php">
<label for="customRange" class="form-label">自定義選擇區(qū)間</label>
<input type="range" class="form-range" id="customRange" name="points">
<label for="customRange" class="form-label">默認(rèn)選擇區(qū)間</label>
<input type="range" id="defaultRange" name="points"><br>
<button type="submit" class="btn btn-primary mt-3">Submit</button>
</form>
</div>
</body>
</html>
默認(rèn)情況下,步長(zhǎng)為 1,可以通過(guò) step 屬性來(lái)設(shè)置:
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap5 實(shí)例</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="stylesheet">
<script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js" rel="external nofollow" rel="external nofollow" rel="external nofollow" ></script>
</head>
<body>
<div class="container mt-3">
<h2>選擇區(qū)間步長(zhǎng)</h2>
<p>默認(rèn)情況下,步長(zhǎng)為 1,可以通過(guò) step 屬性來(lái)設(shè)置:</p>
<form action="/action_page.php">
<label for="customRange" class="form-label">自定義步長(zhǎng)</label>
<input type="range" class="form-range" step="10">
<button type="submit" class="btn btn-primary mt-3">Submit</button>
</form>
</div>
</body>
</html>
默認(rèn)情況下,最小值為 0,最大值為 100,可以通過(guò) min(最?。?或 max(最大) 屬性來(lái)設(shè)置:
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap5 實(shí)例</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="stylesheet">
<script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js" rel="external nofollow" rel="external nofollow" rel="external nofollow" ></script>
</head>
<body>
<div class="container mt-3">
<h2>選擇區(qū)間最大最小值</h2>
<p>默認(rèn)情況下,最小值為 0,最大值為 100,可以通過(guò) min(最?。?或 max(最大) 屬性來(lái)設(shè)置:</p>
<form action="/action_page.php">
<label for="customRange" class="form-label">自定義步長(zhǎng)</label>
<input type="range" class="form-range" min="0" max="4">
<button type="submit" class="btn btn-primary mt-3">Submit</button>
</form>
</div>
</body>
</html>
更多建議: