!DOCTYPE html

創(chuàng)新互聯(lián)專(zhuān)注于企業(yè)營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、網(wǎng)站重做改版、索縣網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5建站、商城系統(tǒng)網(wǎng)站開(kāi)發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性?xún)r(jià)比高,為索縣等各大城市提供網(wǎng)站開(kāi)發(fā)制作服務(wù)。
html lange="en"
head
title點(diǎn)擊左右按鈕圖片橫向滾動(dòng)/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 li.active { background-position:-174px 0; color:#555;cursor:default;}
a.prev,
a.next {background:url()
no-repeat 0 0; display:block;width:23px;height:43px; float:left;
margin:15px 0 0 0; cursor:pointer;}
a.next { background-image:url()}
.scroll_list{ width:10000em; position:absolute; }
/style
!-- 引入jQuery --
script src="" type="text/javascript"/script
script type="text/javascript"
$(function(){
var page= 1;
var i = 4;//每版四個(gè)圖片
//向右滾動(dòng)
$(".next").click(function(){ //點(diǎn)擊事件
var v_wrap = $(this).parents(".scroll"); // 根據(jù)當(dāng)前點(diǎn)擊的元素獲取到父元素
var v_show = v_wrap.find(".scroll_list"); //找到視頻展示的區(qū)域
var v_cont = v_wrap.find(".box"); //找到視頻展示區(qū)域的外圍區(qū)域
var v_width = v_cont.width();
var len = v_show.find("li").length; //我的視頻圖片個(gè)數(shù)
var page_count = Math.ceil(len/i); //只要不是整數(shù),就往大的方向取最小的整數(shù)
if(!v_show.is(":animated")){
if(page == page_count){
v_show.animate({left:'0px'},"slow");
page =1;
}else{
v_show.animate({left:'-='+v_width},"slow");
page++;
}
}
});
//向左滾動(dòng)
$(".prev").click(function(){ //點(diǎn)擊事件
var v_wrap = $(this).parents(".scroll"); // 根據(jù)當(dāng)前點(diǎn)擊的元素獲取到父元素
var v_show = v_wrap.find(".scroll_list"); //找到視頻展示的區(qū)域
var v_cont = v_wrap.find(".box"); //找到視頻展示區(qū)域的外圍區(qū)域
var v_width = v_cont.width();
var len = v_show.find("li").length; //我的視頻圖片個(gè)數(shù)
var page_count = Math.ceil(len/i); //只要不是整數(shù),就往大的方向取最小的整數(shù)
if(!v_show.is(":animated")){
if(page == 1){
v_show.animate({left:'-='+ v_width*(page_count-1)},"slow");
page =page_count;
}else{
v_show.animate({left:'+='+ v_width},"slow");
page--;
}
}
});
});
/script
/head
body
!-- 例子 --
div class="scroll" style="margin:0 auto;width:550px;"
!-- "prev page" link --
a class="prev" href="#"/a
div class="box"
div class="scroll_list"
ul
li1/li
li2/li
li3/li
li4/li
li5/li
li6/li
li7/li
li8/li
li9/li
li10/li
li11/li
li12/li
li13/li
li14/li
li15/li
li16/li
/ul
/div
/div
!-- "next page" link --
a class="next" href="#"/a
/div
/body
/html
(摘自博客園,原網(wǎng)址)
jquery.nicescroll.min.js滾動(dòng)條使用方法,Nicescroll是制作自定義滾動(dòng)條的jq插件。支持div,iframe,html等使用,兼容IE7-8,safari,firefox,webkit內(nèi)核瀏覽器(chrome,safari)以及智能終端設(shè)備瀏覽器的滾動(dòng)條。
頁(yè)面使用:
$("html").niceScroll({
cursorcolor:"#E62020",
cursoropacitymax:1,
touchbehavior:false,
cursorwidth:"10px",
cursorborder:"0",
cursorborderradius:"5px"
})
nicescroll詳細(xì)參數(shù)配置:
cursorcolor - 設(shè)置滾動(dòng)條顏色,默認(rèn)值是“#000000”
cursoropacitymin - 滾動(dòng)條透明度最小值
cursoropacitymax - 滾動(dòng)條透明度最大值
cursorwidth - 滾動(dòng)條的寬度像素,默認(rèn)為5(你可以寫(xiě)“5PX”)
cursorborder - CSS定義邊框,默認(rèn)為“1px solid #FFF”
cursorborderradius - 滾動(dòng)條的邊框圓角
ZIndex的 - 改變滾動(dòng)條的DIV的z-index值,默認(rèn)值是9999
scrollspeed - 滾動(dòng)速度,默認(rèn)值是60
mousescrollstep - 滾動(dòng)鼠標(biāo)滾輪的速度,默認(rèn)值是40(像素)
touchbehavior - 讓滾動(dòng)條能拖動(dòng)滾動(dòng)觸摸設(shè)備默認(rèn)為false
hwacceleration - 使用硬件加速滾動(dòng)支持時(shí),默認(rèn)為true
boxzoom - 使變焦框的內(nèi)容,默認(rèn)為false
dblclickzoom - (僅當(dāng)boxzoom = TRUE)變焦啟動(dòng)時(shí),雙點(diǎn)擊框,默認(rèn)為true
gesturezoom - boxzoom = true并使用觸摸設(shè)備)變焦(僅當(dāng)激活時(shí),間距/盒,默認(rèn)為true
grabcursorenabled“搶”圖標(biāo),顯示div的touchbehavior = true時(shí),默認(rèn)值是true
autohidemode,如何隱藏滾動(dòng)條的作品,真正的默認(rèn)/“光標(biāo)”=只光標(biāo)隱藏/ FALSE =不隱藏
的背景下,改變鐵路背景的CSS,默認(rèn)值為“”
iframeautoresize中,AUTORESIZE iframe上的load事件(默認(rèn):true)
cursorminheight,設(shè)置最低滾動(dòng)條高度(默認(rèn)值:20)
preservenativescrolling,您可以用鼠標(biāo)滾動(dòng)本地滾動(dòng)的區(qū)域,鼓泡鼠標(biāo)滾輪事件(默認(rèn):true)
railoffset,您可以添加抵消頂部/左軌位置(默認(rèn):false)
bouncescroll,使?jié)L動(dòng)反彈結(jié)束時(shí)的內(nèi)容移動(dòng)(僅硬件ACCELL)(默認(rèn):FALSE)
spacebarenabled,允許使用空格鍵滾動(dòng)(默認(rèn):true)
railpadding,設(shè)置間距(默認(rèn):頂:0,右:0,左:0,底部:0})
disableoutline,Chrome瀏覽器,禁用綱要(橙色hightlight)時(shí),選擇一個(gè)div nicescroll(默認(rèn):true)
你好,你需要先明確一個(gè)問(wèn)題,當(dāng)執(zhí)行jQuery的animate方法的時(shí)候,是指從元素當(dāng)前狀態(tài)平滑過(guò)渡到指定狀態(tài)。
當(dāng)你第一次點(diǎn)擊的時(shí)候,當(dāng)前狀態(tài)是 ?top = 0 ?所以,.page元素的 top 會(huì)從 0 變化為 -200px
而當(dāng)你再次點(diǎn)擊時(shí),當(dāng)前狀態(tài)的 ?top = -200px ?了,.page元素的 top 從 -200px 變化為 -200px 自然是沒(méi)反應(yīng)的。
如果你是想實(shí)現(xiàn)每點(diǎn)一次,.page 元素的 top 值都減小 200px,那么可以這么寫(xiě):
$(".down").click(function()?{
var?page?=?$('.page'),
top?=?parseInt(page.css('top'));
top?=?isNaN(top)???-200?:?top?-?200;??????????????
$(".page").stop().animate({top:?top?+?'px'},?800,?'easeInOutExpo');
});
希望能幫你解決問(wèn)題,如有疑問(wèn)歡迎追問(wèn),望采納~~
文章題目:jquery點(diǎn)擊滾動(dòng),jquery 滾動(dòng)
文章起源:http://chinadenli.net/article13/dsgeigs.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、手機(jī)網(wǎng)站建設(shè)、Google、網(wǎng)站改版、外貿(mào)網(wǎng)站建設(shè)、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)