【jquery和swiper组件实现年份时间轴滑动效果】需要用到的组件:Swiper中文网-轮播图幻灯片js插件,H5页面前端开发
html代码:
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title></title><script src="js/jquery-3.4.1.min.js"></script><script src="js/swiper-4.5.3/js/swiper.min.js"></script><link rel="stylesheet" href="js/swiper-4.5.3/css/swiper.min.css" rel="external nofollow" ><link rel="stylesheet" href="css/style.css"></head><body><div class="swiper-container box"><div class="swiper-wrApper main-timeline"><div class="swiper-slide timeline fd-active-line"><a href="JAVAscript:void(0);" rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="timeline-content"><div class="timeline-year"><span>2022</span></div></a><div class="show_timeline"></div></div><div class="swiper-slide timeline"><a href="JavaScript:void(0);" rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="timeline-content"><div class="timeline-year"><span>2021</span></div></a><div class="show_timeline"></div></div><div class="swiper-slide timeline"><a href="javascript:void(0);" rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="timeline-content"><div class="timeline-year"><span>2020</span></div></a><div class="show_timeline"></div></div><div class="swiper-slide timeline"><a href="javascript:void(0);" rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="timeline-content"><div class="timeline-year"><span>2019</span></div></a><div class="show_timeline"></div></div><div class="swiper-slide timeline"><a href="javascript:void(0);" rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="timeline-content"><div class="timeline-year"><span>2018</span></div></a><div class="show_timeline"></div></div><div class="swiper-slide timeline"><a href="javascript:void(0);" rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="timeline-content"><div class="timeline-year"><span>2017</span></div></a><div class="show_timeline"></div></div></div></div><ul class="event_list"><div><h3 id="2022">2022</h3><img src="images/sl01.PNG" alt=""></div><div style="display: none;"><h3 id="2021">2021</h3><img src="images/sl02.PNG" alt=""></div><div style="display: none;"><h3 id="2020">2020</h3><img src="images/sl03.PNG" alt=""></div><div style="display: none;"><h3 id="2019">2019</h3><img src="images/sl04.PNG" alt=""></div><div style="display: none;"><h3 id="2018">2018</h3><img src="images/sl05.PNG" alt=""></div><div style="display: none;"><h3 id="2017">2017</h3><img src="images/sl06.PNG" alt=""></div></ul></div><script>$(function () {$(".main-timeline .timeline").click(function () {var target = $(this).siblings().length;if (target >= 1) {var index = $(this).index()$(this).addClass('fd-active-line').siblings().removeClass('fd-active-line')$(this).parent().parent().siblings('.event_list').children().eq(index).show().siblings().hide()}})var swiper = new Swiper('.swiper-container', {slidesPerView: 4,direction: 'vertical',navigation: {nextEl: '.swiper-button-next',prevEl: '.swiper-button-prev',},on: {resize: function () {swiper.changeDirection(getDirection());}}});});</script></body></html>
推荐阅读
- 几行代码搞定 SpringBoot 接口恶意刷新和暴力请求
- 高级程序员和普通程序员有哪些区别?
- 张三丰从宋朝活到了明朝-?历史上张三丰和朱元璋有关系吗_1
- 春蚕|旧藏·和田玉籽料“春蚕”挂件
- 鱼和熊掌为什么不可兼得 鱼和熊掌不能兼得
- 褒义词和贬义词的4个区别 什么是褒义词
- 底妆|40岁姚笛独自做美容!手里拎十几万名牌包,富豪老公频和美女约会
- 无线鼠标2.4g和蓝牙?蓝牙无线鼠标和2.4g无线鼠标_1
- 食疗丰胸 盘点乳房的最爱和最恨的食物
- 电影|印度版《阿甘正传》正式预告 名场面和名台词重现