Swiper使用方法(向前和向后按钮在swiper-container外面)

Swiper插件的使用

1、HTML

<!-- Swiper -->
<section class="swipper">
 <div class="swiper-button-next"></div>
    <div class="nav-swipper swiper-container  swiper-container-horizontal">
        <div class="swiper-wrapper">
            <div class="swiper-slide"><span class="now"><b><img src="images/swiper-1.png" height="25" width="auto" alt=""></b>股票</span></div>
            <div class="swiper-slide"><span><b><img src="images/swiper-2.png" height="25" width="auto" alt=""></b>债券</span></div>
            <div class="swiper-slide"><span><b><img src="images/swiper-3.png" height="25" width="auto" alt=""></b>公益</span></div>
            <div class="swiper-slide"><span><b><img src="images/swiper-4.png" height="25" width="auto" alt=""></b>实物</span></div>
            <div class="swiper-slide"><span><b>你猜</b>测试</span></div>
            <div class="swiper-slide"><span><b>再猜</b>测试</span></div>
        </div>
        <!-- Add Pagination -->
        <!-- <div class="swiper-pagination"></div> -->
    </div>
    <div class="swiper-button-prev"></div>
    <!-- Swiper End-->
</section>

2、CSS

.nav-swipper{background: #F2F2F2;height: 78px;box-sizing: border-box;}
/*.nav-swipper .swiper-wrapper{margin: 0px 24px;}*/
.nav-swipper .swiper-slide {margin: 0px;text-align: center; font-size: 13px;color: #999; background: #F2F2F2; display: -webkit-box; display: -ms-flexbox; display: -webkit-flex; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; -webkit-align-items: center; align-items: center; }
section.swipper {border-top: 1px solid #979797;padding: 0px 24px;position: relative;}
section.swipper .swiper-button-prev{top:50%;background-image:url(../images/swiper-pre.png);background-size: 12px auto;left: 10px;right: auto;width: 12px;height: 19px;}
section.swipper .swiper-button-next{top:50%;background-image:url(../images/swiper-next.png);background-size: 12px auto;left: auto;right: 10px;width: 12px;height: 19px;}
.nav-swipper span { display: inline-block; vertical-align: top;height: 64px; }
.nav-swipper b { height: 42px; display: table-cell; vertical-align: middle; width: 42px; text-align: center; background: #F7F7F7; border-radius: 50%; border: #fff 1px solid; color: #ccc; box-shadow: 0px 1px 3px #999; }
.nav-swipper span.now b{border-color: #FF6602;}

3、JS

var swiper = new Swiper(‘.nav-swipper‘, {
        pagination: ‘.swiper-pagination‘,
        slidesPerView: 4,
        paginationClickable: true,
        spaceBetween: 0,
        nextButton: ‘.swiper-button-next‘,
        prevButton: ‘.swiper-button-prev‘,
    });

“swiper-button-next”和“swiper-button-prev”两个button是可以脱离在“swiper-container”外面的。因为“swiper-container”的Margin-left起作用,但是Margin-right不起作用(设置了over-flow:hidden),所以没有办法设置“swiper-container”的外边距。但是可以在“swiper-container”外面加一个容器,然后设置它的padding,再把“向左、向右的按钮”放在padding的间距里面。

swiper使用的一般方法如链接所示:http://www.swiper.com.cn/usage/index.html

时间: 2024-12-12 15:46:23

Swiper使用方法(向前和向后按钮在swiper-container外面)的相关文章

普通选项卡+自动播放功能+向前/向后按钮 原生js

今天做了幻灯片,主要功能包括:普通选项卡,向前/向后播放按钮,向前?向后播放功能,自动播放功能 要实现简单选项卡功能是没有问题的,但是添加功能就出现各种各样的问题了 遇到的问题:1 下标问题 2普通选项卡与向前/向后功能结合的时候冲突,可以向前/向后播放,但是再想实现普通选项卡就出问题了3 添加向前/向后按钮后,html布局下移4 添加向前/向后按钮的时候,我用img标签,显然这个不适用,不能很好的调节垂直居中5 当鼠标放在向前/向后按钮上的时候,闪烁,点击的时候也闪烁,而且还点击失效 解决方法

Swiper使用方法(常用介绍)

1.首先加载插件,需要用到的文件有swiper.min.js和swiper.min.css文件. <!DOCTYPE html> <html> <head> ... <link rel="stylesheet" href="path/to/swiper.min.css"> </head> <body> ... <script src="path/to/swiper.min.js&

Java 正则表达式 向前、向后匹配

//向后匹配 String a = "I paid $90 for 10 oranges, 12 pears and 8 apples. I saved $5 on "; Pattern p = Pattern.compile("(?<=\\$)\\d+"); Matcher m = p.matcher(a); while (m.find ()) { String group = m.group (); System.out.println (group);

QT中使用Event Filter监听按钮事件,Release后按钮不见

Accepted : 42   Submit : 122 Time Limit : 1000 MS   Memory Limit : 65536 KB 题目描述 五虎棋是流传在东北民间的一种游戏,GG小的时候,经常被表哥虐得很惨. 由于各个地区的规则可能不大相同,并且GG的回忆不一定很准,所以,如果规则和你平常玩的的有冲突,请以这里为主. 棋盘是横五条,纵五条直线,形成25个交叉点,双方轮流把棋子放到交叉点上 (由于所需各自和棋子数目不多,才12+13,GG小的时候,用的是象棋的棋盘和棋子,真的

C# WebAPI中DateTime类型字段在使用微软自带的方法转json格式后默认含T的解决办法

原文:C# WebAPI中DateTime类型字段在使用微软自带的方法转json格式后默认含T的解决办法 本人新手,在.Net中写WebAPI的时候,当接口返回的json数据含有日期时间类型的字段时,总是在日期和时间中夹着一个字母T:微软这么设置可能有其内在的初衷,但是对于我来说,这样的格式不是很方便,前端同学展示出来的时候也总是要记得处理一下显示格式.曾经问过部门内一位老鸟,老鸟的反应告诉我这在微软的框架下做json转换是不可避免的:当初一度放弃了这个问题.后来突然冷静分析了一下,微软不可能做

导入项目后 出现Unbound classpath container: &#39;JRE System Library [jdk1.6.0_04]&#39; in project &#39;项目名&#39;这样的错误

右键项目-->properties-->java build path--中->libraries.你可以看到JRE Systems Library. 点击Edith进入编辑框.单选框点击alternate JRE.选择SUN JDK 1.6.....完成试试看,不行更改其他的JDK...应该可以解决的. 问题的所在就是项目的JDK和IDE使用的JDK版本不一致,造成未绑定的状态 MyEclipse创建不同版本的jre window-->properties-->Instal

angularjs 水平滚动选中按钮高亮显示 swiper和回到顶部指令的实现ionic

首先安装 swiper npm install --save swiper 或者 bower install --save swiper <link rel="stylesheet" href="../bower_components/swiper/dist/css/swiper.min.css" /> <script src="../bower_components/swiper/dist/js/swiper.jquery.min.js

Swiper使用方法

1.首先加载插件,需要用到的文件有swiper.min.js和swiper.min.css文件. <!DOCTYPE html> <html> <head> ... <link rel="stylesheet" href="path/to/swiper.min.css"> </head> <body> ... <script src="path/to/swiper.min.js&

正则表达式的向前、向后匹配

正则中向前匹配和向后匹配非常强大好用,直接代码. 代码示例: // 向后匹配 // (?=) 匹配 // (?!) 不匹配 $str = "abcx1 abcy2 abcz3"; // 匹配后边是y的abc $a = preg_replace('/abc(?=y)/', '0', $str);// abcx1 0y2 abcz3 // 匹配后边不是y的abc $b = preg_replace('/abc(?!y)/', '1', $str);// 1x1 abcy2 1z3 // =