我正在使用 jQuery UI slider 。如果我将 handle 的高度更改为超过标准 (20px),并单击 slider handle 并将其向任意方向移动 - slider 的 handle 会跳动几个像素。
我希望它不会反弹。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<style type="text/css">
.ui-slider .ui-slider-handle{
height: 30px;
}
</style>
<script>
$(function() {
$(".slider-vertical").slider({
orientation: "vertical",
});
});
</script>
</head>
<body>
<div class="slider-vertical"></div>
</body>
</html>
最佳答案
您只需要像这样更改 .ui-slider-handle
的底部边距:
.ui-slider .ui-slider-handle{
height: 30px;
margin-bottom:-15px;
}
handle 的位置与其高度有关。默认情况下, handle 的高度为 1.2em,为了使 handle 在其位置上居中,它被赋予 1/2 的负底部边距,即 -0.6em,因此如果您需要重新调整 handle 的大小,则必须进行调整底边距也是如此。
基本上 margin-bottom = 0 - height/2
关于jquery-ui - jQuery UI slider 句柄跳转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18431245/