• 手机端页面翻屏


    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
    <link href="style/master.css" rel="stylesheet" type="text/css"/>
    <style>
    html,body{ 100%; height:100%; overflow:hidden;}
    .rel_box{ position:relative; 100%; height:100%; overflow:hidden;}
    #wrap{ position:absolute; 100%; left:0; top:0; overflow:hidden;}
    .screen{ 100%; overflow:hidden;}
    #screen1{ background:url(images/s1_bg.jpg) center top no-repeat #000; background-size:100% auto;}
    #screen2{ background-color:#000}
    #screen3{ background-color:#fff}
    </style>
    <title>翻屏</title>
    </head>
    <body>
    <div class="rel_box">
    <div id="wrap">
    	<!--1-->
    	<div id="screen1" class="screen"></div>
    	<!--2-->
    	<div id="screen2" class="screen"></div>
    	<!--3-->
    	<div id="screen3" class="screen"></div>
    </div>
    </div>
    <script type="text/javascript" src="http://zhuxian.wanmei.com/js/jquery-1.11.2.min.js"></script>
    <script type="text/javascript">
    $(function(){
    	var now = 0, len = $('.screen').size(), touchs = touche = 0, h =$('.rel_box').height();
    	$('.screen').css('height',h);
    	
    	function resetAnm(){//恢复动画原状态
    	
    	}
    	
    	function screenN(n){
    		resetAnm();
    		switch(n) {
    			case 0 :
    				//第一屏加入动画
    				break;
    			case 1 :
    				//第二屏加入动画
    				break;
    			//.....
    		}
    		$('#wrap').css({'transition-duration':'0.3s','transform':'translate3d(0,-'+n*(parseInt(h))+'px,0)'})
    	}
    	$(document).on('touchmove',function(e){
    		e.preventDefault();
    	});
    	$(document).on('touchstart',function(e){
    		touchs = e.originalEvent.touches[0].pageY;
    	});
    	$(document).on('touchend',function(e){
    		touche = e.originalEvent.changedTouches[0].pageY;
    		if(now < (len - 1) && (touche - touchs) < -20){
    			now++;				
    		}
    		if(now > 0 && (touche - touchs) > 20){
    			now--;
    		}
    		screenN(now);
    	});
    });
    </script>
    </body>
    </html>
    

      

  • 相关阅读:
    github 访问速度慢 的解决+个人理解
    phpstorm 编辑器进行自动的注释添加
    输入框只能输入数字(最好用)
    数组去重(根据对象属性去重)
    mac安装Homebrew和 tree
    vue中 .sync 的作用
    打包 vue 组件为 webcomponent
    Android开发之SharedPreferences
    Android开发之SharedPreferences扩展以及File
    Android 开发之SQLite基础
  • 原文地址:https://www.cnblogs.com/bianyuan/p/4431858.html
Copyright © 2020-2023  润新知