首页 技术 正文
技术 2022年11月20日
0 收藏 437 点赞 4,280 浏览 2589 个字

点击预览大图并滑动观看,支持手机端和pc端,具体功能如下图:

点击查看大图滑动预览(h5,pc通用)

一. touchTouch 的js和css 以及jquery依赖库

<link rel="stylesheet" type="text/css" href="touchTouch/touchTouch.css" rel="external nofollow"  rel="external nofollow"  />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="touchTouch/touchTouch.jquery.js" ></script>

二.写入html结构,注意,此处图片需要以background-image的形式插入,a 的href值也是图片地址。 

<div class="img-container" id="thumbs">
<a href="http://images.cnblogs.com/cnblogs_com/a-cat/1193051/o_img_zone.png" rel="external nofollow" rel="external nofollow" style="background-image: url(http://images.cnblogs.com/cnblogs_com/a-cat/1193051/o_img_zone.png);"></a>
<a href="http://images.cnblogs.com/cnblogs_com/a-cat/1193051/o_img_wechat.png" rel="external nofollow" rel="external nofollow" style="background-image: url(http://images.cnblogs.com/cnblogs_com/a-cat/1193051/o_img_wechat.png);"></a>
<a href="http://images.cnblogs.com/cnblogs_com/a-cat/1193051/o_img_xlwb.png" rel="external nofollow" rel="external nofollow" style="background-image: url(http://images.cnblogs.com/cnblogs_com/a-cat/1193051/o_img_xlwb.png);"></a>
</div>

 

三.给结构加入自己想要的样式。

.img-container{
overflow: hidden;
}
.img-container a{
float: left;
width: 2.36rem;
height: 2.36rem;
overflow: hidden;
background-size: 100% 100%;
background-repeat: no-repeat;
}

四.在script中执行方法。

<script>
$(function(){
$('#thumbs a').touchTouch();
})
</script>

加上自己想要的css样式就完成了,下面是 touchTouch 插件包下载地址:

链接: https://pan.baidu.com/s/1_BCUSss8_3i3yiSATyc89w 提取码: h436

注:整个demo结构

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="touchTouch/touchTouch.css" rel="external nofollow" rel="external nofollow" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script type="text/javascript" src="touchTouch/touchTouch.jquery.js" ></script>
    <style>
      .img-container{
        overflow: hidden;
      }
      .img-container a{
        float: left;
        width: 2.36rem;
        height: 2.36rem;
        overflow: hidden;
        background-size: 100% 100%;
        background-repeat: no-repeat;
      }
    </style>
  </head>
  <body>
    <div class="img-container" id="thumbs">
      <a href="http://images.cnblogs.com/cnblogs_com/a-cat/1193051/o_img_zone.png" rel="external nofollow" rel="external nofollow" style="background-image: url(http://images.cnblogs.com/cnblogs_com/a-cat/1193051/o_img_zone.png);"></a>
      <a href="http://images.cnblogs.com/cnblogs_com/a-cat/1193051/o_img_wechat.png" rel="external nofollow" rel="external nofollow" style="background-image: url(http://images.cnblogs.com/cnblogs_com/a-cat/1193051/o_img_wechat.png);"></a>
      <a href="http://images.cnblogs.com/cnblogs_com/a-cat/1193051/o_img_xlwb.png" rel="external nofollow" rel="external nofollow" style="background-image: url(http://images.cnblogs.com/cnblogs_com/a-cat/1193051/o_img_xlwb.png);"></a>
    </div>
    <script>
      $(function(){
        $('#thumbs a').touchTouch();
      })
    </script>
  </body>
</html>

  

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,910
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,435
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,250
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,061
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,693
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,731