實現圖片滾動

來源:互聯網
上載者:User

標籤:

簡要:

 簡要代碼:

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>    <title>滾動圖片效果展示</title>    <script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.js"></script>    <script src="http://cdn.bootcss.com/velocity/1.2.3/velocity.js"></script>    <style type="text/css">       div:not(:last-of-type){           width:80%;height:750px;margin:0 auto;       }       div:first-of-type{background:url(imgs/1.jpg);background-size:cover;}       div:nth-of-type(2){background:url(imgs/2.jpg);background-size:cover;}       div:nth-of-type(3){background:url(imgs/3.jpg);background-size:cover;}       div:nth-of-type(4){background:url(imgs/4.jpg);background-size:cover;}       div:nth-of-type(5){background:url(imgs/5.jpg);background-size:cover;}       div:nth-of-type(6){background:url(imgs/6.jpg);background-size:cover;}       div:nth-of-type(7){background:url(imgs/7.jpg);background-size:cover;}       div:last-of-type{position:fixed;top:130px;right:50px;}       div:last-of-type ul{list-style:none;}       div:last-of-type ul li{width:30px;height:30px;background:black;margin:3px;color:white;text-align:center;line-height:30px;}        div:last-of-type ul li:hover {cursor:pointer; }         </style></head><body>    <div></div>    <div></div>    <div></div>    <div></div>    <div></div>    <div></div>    <div></div>    <div>        <ul><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li></ul>    </div></body></html><script type="text/javascript">    $("div:last ul li").click(function () {        var numLi = $(this).text();        $("div:last ul li").css({ "background-color": "black", "color": "white" });//每次都對所有的li背景色進行初始化,點擊哪個改變哪個li的背景顏色和字型顏色        switch (numLi) {            case "1": $("div:first").velocity("scroll", { duration: 300 }); $(this).css({"background-color":"white","color":"black"});break;            case "2": $("div:eq(1)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;            case "3": $("div:eq(2)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;            case "4": $("div:eq(3)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;            case "5": $("div:eq(4)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;            case "6": $("div:eq(5)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;            case "7": $("div:eq(6)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;        }    }); </script>

 

實現圖片滾動

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.