繁体   English   中英

使用css和jquery的可滚动div

[英]scrollable div using css and jquery

我想为我的div做自定义滚动。 我已经写了一些代码,但是不能正常工作。 首先,它在mousemove上。 这应该像其他滚动作品一样工作。 小提琴

这是代码

var height = $('.frm').height(),
overflowHeight= $('.overflow').height();    
var finalheight = overflowHeight-height;
$('.tab').mousemove(function(e){
var top= parseInt($('.tab').css('top'));
var ac= top;
$('.overflow').css({top:-ac})
var y= e.pageY;
$(this).css({top:y})    

我对您的代码做了一些更改,

var height = $('.frm').height(),
overflowHeight= $('.overflow').height();    
var finalheight = overflowHeight-height;

$('.scroll').mousemove(function(e){
    var top= parseInt($('.tab').css('top'));
    var ac= top;
    $('.overflow').css({top:-ac})
    var y= e.clientY;
    $(".tab").css({top:y})  
});

小提琴http://jsfiddle.net/v6qsu/2/

此外,还有许多库可用于自定义滚动,例如jscrollpane

http://jscrollpane.kelvinluck.com/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM