search
HomeWeb Front-endJS TutorialThe specific code for a navigation scrolling effect implemented by jquery_jquery

When I was building a campus video website, there was a navigation page on the homepage that needed to achieve a scrolling effect. There were examples, but the code was difficult to understand. It seemed that in web design, only my own code was understood, so I simply imitated the effects of others. I made one myself, and it's generally OK. It looks relatively smooth, not inferior to the original one.

Copy the code here now, and simplify the modifications one by one later:
To achieve the scrolling effect, the script code is as follows:

Copy the code The code is as follows:

var all=0;
var no=0;
var s_width=0;
$(document).ready( function(){
all=$('.slide').length;
s_width=$('.slide').eq(0).width();
$("#slides" ).css('width',all*s_width);
var contiar=$('.control_links');
for(var i=0;icontiar.append ("
  • ");
    }
    $('.control_links li').bind('click mouseenter',function(){
    var index=$(this ).index();
    no=index;
    var no_= no%all;
    $("#slides").animate({left:(-1*no_*s_width) 'px' },200);
    $(this).css('background-color','#fff');
    $(this).siblings().css('background-color','#333 ');
    });
    setInterval(function(){
    var no_= no%all;
    $("#slides").animate({left:(-1*no_* s_width) 'px'},1000);
    var curr= $('.control_links li').eq(no_);
    curr.css('background-color','#fff')
    curr.siblings().css('background-color','#333');
    no ;
    },5000);
    });

  • css The code is as follows:
    Copy code The code is as follows:

    img{
    border:none;
    }
    #daohangpic {
    width:1000px;
    margin:0 auto;
    padding:20px;
    overflow:hidden;
    }
    #daohangpic img {
    height:380px;
    width:980px;
    }

    #contiar {
    position:relative;
    width:980px;
    height:380px;
    overflow:hidden;
    margin:0 auto;
    }
    #slides {
    position:absolute;
    border:none;
    }
    .slide {
    float:left;
    width:980px;
    height:380px;
    overflow:hidden;
    border:none;
    }
    .control_links{
    position:absolute;
    bottom:10px;
    right:10px;
    z-index:200;
    }
    .control_links,.control_links li {
    list-style: none;
    }
    .control_links li {
    float:left;
    width: 15px;
    height: 15px;
    margin-right: 5px;
    text-align: center;
    background: #333;
    border: 1px solid #666;
    cursor: pointer;
    opacity:0.5;
    }
    .caption {
    position:absolute;
    height:50px ;
    width:100%;
    background-color:#000;
    bottom:0px;
    padding-left:20px;
    padding-top:10px;
    overflow:hidden ;
    z-index:100;
    background:url(hdpng.png) no-repeat scroll 0 -1px;
    }
    .caption h2 {
    color: #FFF;
    font-size: 17px;
    font-weight: bold;
    line-height:25px;
    }
    .caption p{
    display: block;
    color: #767676 ;
    font-size:12px;
    line-height:15px;
    }

    The area to be scrolled is defined as follows:
    Copy code The code is as follows:




    Slide 1

    grid The list of Les Mills winners was announced


    The list of Grammy winners was announced, and all the big names sang at the awards ceremony



    div> 569736869323031336368756E77616E2F312E6D6B76" title="Popular celebrities at home and abroad gather together , Uncle Bird Lin Chiling performed a horse-riding dance" target="_blank">Slide 1

    The list of Grammy winners was announced


    The list of Grammy winners was announced, and all the big names sang at the awards ceremony


    < ;/div>
    8696E7869616F616F6A69616E6768752F2A2A2E6D6B76 " title="Three episodes of sadomasochism between Linghu Chong, Dongfang Bubai and Ren Yingying are tear-jerking" target="_blank">Slide 1

    The list of Grammy winners was announced


    The list of Grammy winners was announced, and all the big names sang at the awards ceremony


    下注


    Slide 1


    The list of Grammy winners was announced, and all the big names sang at the awards ceremony




    Slide 1

    The list of Grammy winners was announced


    The list of Grammy winners was announced, and all the big names sang at the awards ceremony


    div>







    Statement
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    JavaScript 如何实现滚动到指定元素位置的功能?JavaScript 如何实现滚动到指定元素位置的功能?Oct 22, 2023 am 08:12 AM

    JavaScript如何实现滚动到指定元素位置的功能?在网页中,当我们需要将用户的视线聚焦到某个特定的元素位置时,我们可以使用JavaScript来实现滚动到指定元素位置的功能。本文将介绍如何通过JavaScript实现这一功能,并提供相应的代码示例。首先,我们需要获取目标元素的位置信息。可以使用Element.getBoundingClient

    足球导航语音包在哪个导航软件足球导航语音包在哪个导航软件Nov 09, 2022 pm 04:33 PM

    足球导航语音包在“高德导航”软件中,是高德地图车机版导航语音包的其中一种,内容为黄健翔足球解说版本的导航语音。设置方法:1、打开高德地图软件;2、点击进入“更多工具”-“导航语音”选项;3、找到“黄健翔热血语音”,点击“下载”;4、在弹出的页面,点击“使用语音”即可。

    百度地图 App 最新版本 18.8.0 发布,首次引入红绿灯雷达功能,并新增实时停车推荐功能百度地图 App 最新版本 18.8.0 发布,首次引入红绿灯雷达功能,并新增实时停车推荐功能Aug 06, 2023 pm 06:05 PM

    百度地图App安卓版/iOS版均已发布18.8.0版本,首次引入红绿灯雷达功能,业内领先据官方介绍,开启红绿灯雷达后,支持开车自动探测红绿灯,不用输入目的地,北斗高精可以实时定位,全国100万+红绿灯自动触发绿波提醒。除此之外,新功能还提供全程静音导航,使图区更简洁,关键信息一目了然,且无语音播报,使驾驶员更加专注驾驶百度地图于2020年10月上线红绿灯倒计时功能,支持实时读秒预判,导航会在接近红绿灯路口时,自动展示倒计时剩余秒数,让用户时刻掌握前方路况。截至2022年12月31日,红绿灯倒计时

    导航地图上横着的8字是什么导航地图上横着的8字是什么Jun 27, 2023 am 11:43 AM

    导航地图上横着的8字是霾,中度是黄色8预警信号,重度是橙色8预警信号。

    高德地图推出升级版驾车 ETA 服务:实时解析当前路况,预估到达时间更精准高德地图推出升级版驾车 ETA 服务:实时解析当前路况,预估到达时间更精准Apr 30, 2024 am 08:37 AM

    本站4月29日消息,高德地图官宣推出升级版的驾车ETA(本站注:ETA即预估到达时间,指的是用户在当前时刻出发按照给定路线前往目的地预计需要的时长)服务,该服务旨在帮助用户的路线规划时长和路况预估更为精准,辅助用户进行出行决策。该地图应用是最新升级的高德地图App,引入了“超大规模图卷积神经网络模型”,该模型可以更好地捕捉和学习交通流动规律,支持城市道路网络、高速公路系统,能以高精度刻画交通状况的时空动态变化。在此外,全新版本的地图还进一步融合了iTransformer时序预测模型,支持实时解析

    uniapp中如何实现页面跳转和导航uniapp中如何实现页面跳转和导航Oct 20, 2023 pm 02:07 PM

    uniapp中如何实现页面跳转和导航uniapp是一款支持一次编码多端发布的前端框架,它基于Vue.js,开发者可以使用uniapp快速开发移动端应用。在uniapp中,实现页面跳转和导航是非常常见的需求。本文将介绍uniapp中如何实现页面跳转和导航,并提供具体的代码示例。一、页面跳转使用uniapp提供的方法进行页面跳转uniapp提供了一组方法用于实现

    JavaScript 如何实现图片的滚动切换效果?JavaScript 如何实现图片的滚动切换效果?Oct 20, 2023 pm 05:51 PM

    JavaScript如何实现图片的滚动切换效果?在现代网页设计中,图片滚动切换效果是常用的设计要素之一,它能够为网页增添动感和生动性。而JavaScript作为一种常用的脚本语言,可以帮助我们实现这一效果。在本文中,我将介绍一种使用JavaScript实现图片滚动切换效果的方法,并提供相应的代码示例。首先,我们需要准备一个用于显示图片的HTML结构。具体代

    如何通过Vue实现图片的浏览和缩略图导航?如何通过Vue实现图片的浏览和缩略图导航?Aug 18, 2023 pm 02:51 PM

    如何通过Vue实现图片的浏览和缩略图导航?随着Web应用程序的发展,图片在我们的日常生活中扮演着越来越重要的角色。在许多情况下,我们需要实现图片的浏览和缩略图导航功能。这篇文章将介绍如何利用Vue框架实现这一功能,并提供代码示例。在Vue中,我们可以使用Vue插件来实现图片的浏览和缩略图导航功能。一个流行的插件是vue-gallery,它提供了简单易用的接口

    See all articles

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Best Graphic Settings
    3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. How to Fix Audio if You Can't Hear Anyone
    3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    mPDF

    mPDF

    mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

    SublimeText3 English version

    SublimeText3 English version

    Recommended: Win version, supports code prompts!

    MinGW - Minimalist GNU for Windows

    MinGW - Minimalist GNU for Windows

    This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

    ZendStudio 13.5.1 Mac

    ZendStudio 13.5.1 Mac

    Powerful PHP integrated development environment

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment