使用jq和css3自制图片滚轮

2024-05-30 02:58

本文主要是介绍使用jq和css3自制图片滚轮,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

效果展示
效果展示

这边做的层次感不是很明显,可以自己调节css

目标效果

  • 左右按钮控制图片左右切换
  • 备注信息从下往上缓慢滑出

思路

  • 信息滑出很简单,用css3做就行
  • 左右控制图片,使用定位做,给五个图片分别定位,命名5个class,当右切换,最左边的class切换成默认left,然后从左至右从新给予定义好的五个class

做法

  • 信息从下往上滑出
/*info应该被包裹在box里*/
.box{position: relative;
}.box .info{position: absolute;left: 0;bottom: 0;transition: height 0.6s;width: 100%;height: 0;
}.box:hover > .info{height: auto;    /*或者其他定高*/
}
  • 切换图片

这里写图片描述

切换前new img定位和right-2同样位置,但是z-index比right-2低,隐藏在他下面

切换后的默认样式也是,定位在left-1下面

js

$(".turn-right").click(function(){if($(".main").next().prop('class') === undefined){return false;}$(".left-1").prop('class','match-item left');$(".left-2").prop('class','match-item left-1');$(".main").prop('class','match-item left-2');$(".right-1").prop('class','match-item main');var right = $(".right-2");right.prop('class','match-item right-1');right.next().prop('class','match-item right-2');
});$(".turn-left").click(function(){if($(".main").prev().prop('class') === undefined){return false;}$(".right-2").prop('class','match-item right');$(".right-1").prop('class','match-item right-2');$(".main").prop('class','match-item right-1');$(".left-2").prop('class','match-item main');var left = $(".left-1");left.prop('class','match-item left-2');left.prev().prop('class','match-item left-1');
});

html

<div class="slide"><div class="turn-left"><span class="arrow-left"></span></div><ul class="match-list pst"><li class="match-item left-1"><img src="1.png" alt="" width="100%" /><div class="info"><p>球场:<span class="color-blue">成都观岭</span></p><p>一杆进洞奖金:<span class="color-yellow">2000元</span></p><p>2017.05.01~2017.05.31</p></div></li><li class="match-item left-2"><img src="2.png" alt="" width="100%" /><div class="info"><p>球场:<span class="color-blue">成都观岭</span></p><p>一杆进洞奖金:<span class="color-yellow">2000元</span></p><p>2017.05.01~2017.05.31</p></div></li><li class="match-item main"><img src="3.png" alt="" width="100%" /><div class="info"><p>球场:<span class="color-blue">成都观岭</span></p><p>一杆进洞奖金:<span class="color-yellow">2000元</span></p><p>2017.05.01~2017.05.31</p></div></li><li class="match-item right-1"><img src="1.png" alt="" width="100%" /><div class="info"><p>球场:<span class="color-blue">成都观岭</span></p><p>一杆进洞奖金:<span class="color-yellow">2000元</span></p><p>2017.05.01~2017.05.31</p></div></li><li class="match-item right-2"><img src="2.png" alt="" width="100%" /><div class="info"><p>球场:<span class="color-blue">成都观岭</span></p><p>一杆进洞奖金:<span class="color-yellow">2000元</span></p><p>2017.05.01~2017.05.31</p></div></li><li class="match-item"><img src="3.png" alt="" width="100%" /><div class="info"><p>球场:<span class="color-blue">成都观岭</span></p><p>一杆进洞奖金:<span class="color-yellow">2000元</span></p><p>2017.05.01~2017.05.31</p></div></li></ul><div class="turn-right"><span class="arrow-right"></span></div><div class="clearfix"></div>
</div>

css

.match .turn-left,.match .turn-right{display: inline-block;vertical-align: middle;width: 80px;height: 400px;cursor: pointer;margin: 0 20px;
}.match .turn-left:hover{background: linear-gradient(to left,rgba(96,110,122,0.8),rgba(96,110,122,0));
}.match .turn-right:hover{background: linear-gradient(to right,rgba(96,110,122,0.8),rgba(96,110,122,0));
}.match .turn-left .arrow-left,.match .turn-right .arrow-right{position: relative;
}.match .turn-left .arrow-left:before{content: '';display: inline-block;width: 50px;height: 10px;transform: skewY(-45deg);background-color: #eee;position: absolute;top: 150px;left: 15px;
}.match .turn-left .arrow-left:after{content: '';display: inline-block;width: 50px;height: 10px;transform: skewY(45deg);background-color: #eee;position: absolute;top: 200px;left: 15px;
}.match .turn-right .arrow-right:before{content: '';display: inline-block;width: 50px;height: 10px;transform: skewY(45deg);background-color: #eee;position: absolute;top: 150px;left: 15px;
}.match .turn-right .arrow-right:after{content: '';display: inline-block;width: 50px;height: 10px;transform: skewY(-45deg);background-color: #eee;position: absolute;top: 200px;left: 15px;
}.match .match-list{width: 800px;height: 405px;padding: 20px 0;vertical-align: middle;display: inline-block;white-space: nowrap;overflow-x: hidden;overflow-y: hidden;position: relative;
}.match .match-item{z-index: 100;position: absolute;top: 72px;left: 550px;width: 200px;height: 300px;display: inline-block;margin: 0 10px 10px;box-shadow: 0 1px 8px 2px rgba(1,1,1,0.8);border-radius: 2px;transition: all 1s;cursor: pointer;vertical-align: middle;
}.match .match-item:hover{transform: scale(1.05);box-shadow: 0 1px 10px 4px rgba(1,1,1,0.8);
}.match .left-1{z-index: 300 !important;position: absolute;top: 72px;left: 10px;width: 200px;height: 300px;
}.match .left-2{z-index: 400 !important;position: absolute;top: 35px;left: 145px;width: 250px;height: 375px;
}.match .main{z-index: 500 !important;position: absolute;top: 20px;left: 280px;width: 270px;height: 405px;
}.match .right-1{z-index: 400 !important;position: absolute;top: 35px;left: 415px;width: 250px;height: 375px;
}.match .right-2{z-index: 300 !important;position: absolute;top: 72px;left: 550px;width: 200px;height: 300px;
}.match .left{z-index: 100;position: absolute;top: 72px;left: 10px;width: 200px;height: 300px;
}.match .right{z-index: 100;position: absolute;top: 72px;left: 550px;width: 200px;height: 300px;
}.match .info{position: absolute;left: 0;bottom: 0;width: 100%;height: 0;overflow: hidden;padding: 0;z-index: 200;transition: all 1s;background-color: rgba(0,0,0,0.6);
}.match .main .info{height: 120px;
}.match .info p{font-size: 16px;font-family: SourceHanSansCN-Medium, sans-serif;color: #f0f0f0;margin: 5px 10px;padding: 0;line-height: 30px;height: 30px;text-shadow: 1px 1px rgba(1,1,1,0.6);
}.match .info .color-blue{color: #00a1fe;font-size: 18px;
}.match .info .color-yellow{color: #e07e3e;font-size: 18px;
}

这篇关于使用jq和css3自制图片滚轮的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1015393

相关文章

Java学习手册之Filter和Listener使用方法

《Java学习手册之Filter和Listener使用方法》:本文主要介绍Java学习手册之Filter和Listener使用方法的相关资料,Filter是一种拦截器,可以在请求到达Servl... 目录一、Filter(过滤器)1. Filter 的工作原理2. Filter 的配置与使用二、Listen

Pandas使用AdaBoost进行分类的实现

《Pandas使用AdaBoost进行分类的实现》Pandas和AdaBoost分类算法,可以高效地进行数据预处理和分类任务,本文主要介绍了Pandas使用AdaBoost进行分类的实现,具有一定的参... 目录什么是 AdaBoost?使用 AdaBoost 的步骤安装必要的库步骤一:数据准备步骤二:模型

使用Pandas进行均值填充的实现

《使用Pandas进行均值填充的实现》缺失数据(NaN值)是一个常见的问题,我们可以通过多种方法来处理缺失数据,其中一种常用的方法是均值填充,本文主要介绍了使用Pandas进行均值填充的实现,感兴趣的... 目录什么是均值填充?为什么选择均值填充?均值填充的步骤实际代码示例总结在数据分析和处理过程中,缺失数

如何使用 Python 读取 Excel 数据

《如何使用Python读取Excel数据》:本文主要介绍使用Python读取Excel数据的详细教程,通过pandas和openpyxl,你可以轻松读取Excel文件,并进行各种数据处理操... 目录使用 python 读取 Excel 数据的详细教程1. 安装必要的依赖2. 读取 Excel 文件3. 读

关于MongoDB图片URL存储异常问题以及解决

《关于MongoDB图片URL存储异常问题以及解决》:本文主要介绍关于MongoDB图片URL存储异常问题以及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录MongoDB图片URL存储异常问题项目场景问题描述原因分析解决方案预防措施js总结MongoDB图

解决Maven项目idea找不到本地仓库jar包问题以及使用mvn install:install-file

《解决Maven项目idea找不到本地仓库jar包问题以及使用mvninstall:install-file》:本文主要介绍解决Maven项目idea找不到本地仓库jar包问题以及使用mvnin... 目录Maven项目idea找不到本地仓库jar包以及使用mvn install:install-file基

Python使用getopt处理命令行参数示例解析(最佳实践)

《Python使用getopt处理命令行参数示例解析(最佳实践)》getopt模块是Python标准库中一个简单但强大的命令行参数处理工具,它特别适合那些需要快速实现基本命令行参数解析的场景,或者需要... 目录为什么需要处理命令行参数?getopt模块基础实际应用示例与其他参数处理方式的比较常见问http

python实现svg图片转换为png和gif

《python实现svg图片转换为png和gif》这篇文章主要为大家详细介绍了python如何实现将svg图片格式转换为png和gif,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录python实现svg图片转换为png和gifpython实现图片格式之间的相互转换延展:基于Py

C 语言中enum枚举的定义和使用小结

《C语言中enum枚举的定义和使用小结》在C语言里,enum(枚举)是一种用户自定义的数据类型,它能够让你创建一组具名的整数常量,下面我会从定义、使用、特性等方面详细介绍enum,感兴趣的朋友一起看... 目录1、引言2、基本定义3、定义枚举变量4、自定义枚举常量的值5、枚举与switch语句结合使用6、枚

使用Python从PPT文档中提取图片和图片信息(如坐标、宽度和高度等)

《使用Python从PPT文档中提取图片和图片信息(如坐标、宽度和高度等)》PPT是一种高效的信息展示工具,广泛应用于教育、商务和设计等多个领域,PPT文档中常常包含丰富的图片内容,这些图片不仅提升了... 目录一、引言二、环境与工具三、python 提取PPT背景图片3.1 提取幻灯片背景图片3.2 提取