jquery点击按钮图片上下滚动怎么做

jquery点击按钮图片上下滚动怎么做,第1张

<!DOCTYPE html>

<html lange="en">

<head>

<title>点击左右按钮横向滚动</title>

<meta charset=utf-8" />

<style type="text/css">

{ margin:0; padding:0;}

body { font-size:12px;}

box {height:66px; float:left; width:440px; overflow: hidden; position:relative; }

box

li { display:block; float:left; margin-left:5px; margin-right:5px;

width:100px;

height:70px;background:#BBB;font-size:50px;color:#ccc;line-height:66px;text-decoration:none;text-align:center;

cursor:pointer;}

box li:hover { color:#999; }

box liactive { background-position:-174px 0; color:#555;cursor:default;}

aprev,

anext {background:url(><script src=">

这里有一个方法可以将DIV的滚动条滚动到其子元素所在的位置,方便自动定位。

复制代码

代码如下:

var

container

=

$('div'),

scrollTo

=

$('#row_8');

containerscrollTop(

scrollTooffset()top

-

containeroffset()top

+

containerscrollTop()

);

//

Or

you

can

animate

the

scrolling:

containeranimate({

scrollTop:

scrollTooffset()top

-

containeroffset()top

+

containerscrollTop()

});​

不需要任何JQuery插件即可完成所需的效果,非常好用!

var h1 = $(window)height();

$(documentbody)css({"height": h1 -"50" });

$(document)css({"overflow":"hidden"});

这个应该可以吧

前置条件:

div作为盒子限制高度,并设置overflow:auto。在内容超溢出时会出现滚动条(默认Y轴)

实现滚动条滚动到指定位置有两种情况:无效果 和 有动画效果

(1)无效果--直接使用scrollTop方法

//100为高度,单位px

$('box')scrollTop(100)

(2)有效果--使用animate方法

//100为高度,单位px;300为时间,单位ms

$('box')animate({scrollTop:100},300)

以上就是关于jquery点击按钮图片上下滚动怎么做全部的内容,包括:jquery点击按钮图片上下滚动怎么做、jquery如何获取DIV包含滚动条在内的高度、通过JQuery将DIV的滚动条滚动到指定的位置方便自动定位等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9607741.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-30
下一篇2023-04-30

发表评论

登录后才能评论

评论列表(0条)

    保存