移动端框架篇-控制父容器的滑屏框架-slip.js

设计滑屏框架的办法一般有2种

  • 控制父容器法
  • 控制子容器法

这个算是控制父容器法

通过控制父容器的transform: translateY或margin-top或top的值来上下滑动页面,每次的位移的取值为当前页面高度~

这里采用slip框架,库大小5.75K,非常轻量,可以放心用在你的项目~

slip框架的页面样式需要自定义,不过这里我简单写好了~

(如果你不使用框架,推荐用transform: translate(X,Y)的写法,首先transform: translate可设计高性能动画,其次兼容android2.3+的系统,transform: translateY不兼容android2.3的系统)

兼容ios5+、android2.3+系统,其滑屏功能,响应灵敏~如果你只需要设计简单的滑屏效果,可考虑它~

slip框架更多详细的功能猛击这里https://github.com/binnng/slip.js

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<title>slip</title>
<style>
*{padding: 0;margin: 0;}
/*框架*/
.swipe-wrap{width: 100%;height: 100%;position: relative;overflow: hidden;}
.swipe{position:absolute;width:100%;}
.swipe-box{width: 100%;overflow: hidden;}
</style>

</head>

<body> 

<div class="swipe-wrap" id="slip">
    <article class="swipe">

        <div class="swipe-box" style="background-color: gray;">
        第1屏
        </div>

        <div class="swipe-box" style="background-color: green;">
        第2屏
        </div>

        <div class="swipe-box" style="background-color: orange;">
        第3屏
        </div>

        <div class="swipe-box" style="background-color: blue;">
        第4屏
        </div>

    </article>
</div>

</body>

<script type="text/javascript" src="js/slip.min.js"></script>
<script type="text/javascript">
var container = document.getElementById(‘slip‘);
var pages = document.querySelectorAll(‘.swipe-box‘);
var slip = Slip(container, ‘y‘).webapp(pages);
</script>

</html>

DEMO

时间: 2024-08-01 22:42:55

移动端框架篇-控制父容器的滑屏框架-slip.js的相关文章

移动端框架篇-控制子容器的滑屏框架-fullPage.js

控制子容器法 方法是只显示其中一个子元素,其它隐藏,滑屏时隐藏当前元素,并显示当前元素的下一个同辈元素~ 这里采用fullPage框架,库大小7.69K~ fullPage框架的页面样式无需自定义,已有写好的 兼容ios5+.android2.3+.winphone 8系统,其滑屏功能,效果比较丰富,支持缩放.旋转.透明度.自动滑屏等动画效果~如果你需要设计精彩的滑屏效果,可考虑它~ fullPage框架更多详细的功能猛击这里https://github.com/powy1993/fullpag

实现未知高度父容器及其左右排列子容器的高度自适应的办法

1 <div class="container"> 2 <div class="content-1">未知高度和宽度的内容</div> 3 <div class="content-2">未知高度和宽度内容</div> 4 </div> 需要实现两个子容器中一个依据另外一个的高度而自动等高,同时父容器也是同样自动等高,宽度可以自适应或者按需分配. 目前我学习到的两种解决办法一种

IsMdicontainer新窗体被父容器包括的设置、Timer控件

IsMdicontainer的设置 这是对于整个窗体的设置,将一个窗体的IsMdicontainer设置为true之后,再打开新窗体便可以让新窗体被父容器包括在内. 操作方法: 1)先建立一个子窗体Child.cs 2)在父容器的按钮里写代码,打开子窗体 Child c = new Child(); //判断窗体是否已经打开,以控制其只能打开一个 int count = 0; foreach (Form f in this.MdiChildren) { if (f.Name == c.Name)

textarea 自适应父容器大小

<div id="collapse-panel-4" class="am-panel-bd am-collapse am-in"> <textarea cols="80" rows="50" id="msg" class="comments"></textarea> </div> /* textarea 自适应父容器大小 */ .comme

Spring - 父容器与子容器

一.Spring容器(父容器) 1.Mapper代理对象 2.Service对象 二.Springmvc(前端控制器)(子容器)        Controller对象 1.标准的配置是这样的:Controller只在SpringMVC的配置文件扫描.Service等只在Spring容器的配置文件配置扫描.        2.Spring中也可以扫描Controller,但是使用时还是使用的SpringMVC自己的(自己没有配置,那么不能用),造成对象冗余,而且使用时事务控制可能有问题.   

H5弹性盒布局的使用(父容器属性)

为父容器添加display:flex/inline-flex 父容器可以使用的属性有: 1.flex-direction:决定主轴的方向 有四个属性值: row(默认值):主轴为水平方向,起点在左端. row-reverse:主轴为水平方向,起点在右端. column:主轴为垂直方向,起点在上沿. column-reverse:主轴为垂直方向,起点在下沿. 2.flex-wrap:如果一条轴线排不下,如何换行. 有3个属性值: nowrap(默认):不换行.当父容器宽度不够时每个item会被适当

父容器为inline-block的导航栏

常见的水平导航栏实现方法有: 1.li {display:inline} 缺点:内联元素,无法设置长与宽 2.li {float:left} 缺点:需要清除浮动 3.li {display:inline-block} 缺点:每个inline-block之间有4px的空白 本文介绍的方法是:将父元素设置为inline-block,子元素浮动 <ul> <li>abc</li> <li>bcd</li> <li>cde</li>

文本框样式width100%超过父容器

input[type="text"] { width: 100%; box-sizing: border-box; -webkit-box-sizing:border-box; -moz-box-sizing: border-box; } 解决文本框样式width:100%超过父容器!!! 转载自:http://blog.csdn.net/xiaochunyong/article/details/7517210

关于撑开父容器高度的小探讨

我们知道,当子元素float的时候,虽然没有脱离文本流,但是也会使父元素坍缩,也就是父元素的高度或者宽度变为0,解决办法就是让父元素的overflow为hidden. 今天我遇到一个bug,如下代码所示: <div class="wrap"> <div class="main"> <img src="../JS+CSS3实现带预览图幻灯片效果/images/1.jpg" height="500"