html5在移动开发中的准则
2017-12-04 00:00
169 查看
尽量使用单页面开发(SPA)
慎重选择前端UI框架
动画、特性使用准则(60fps)
长度单位使用rem
位置-tranform: translate(x,y,z)
大小-tranform: scale(n)
旋转-tranform: rotate(ndeg)
透明度-opacity: 0..1
http://csstriggers.com/
结合jquery代码如下:
慎重选择前端UI框架
动画、特性使用准则(60fps)
长度单位使用rem
浏览器消耗最小的css属性
位置-tranform: translate(x,y,z)
大小-tranform: scale(n)
旋转-tranform: rotate(ndeg)
透明度-opacity: 0..1
http://csstriggers.com/
实现手机点击事件
基于touchstart、touchend和touchmove三个基础事件实现点击事件结合jquery代码如下:
$(function() { var size = $(window).width()/18; //设备宽度除以18 $("html").css("font-size", size); var myscroll = new IScroll("#file-list"); //用ISscroll实现内容滚动 $("#file-list li").bindtouch(function() { $(this).remove(); }) }); $.fn.bindtouch = function(cb) { attachEvent($(this), cb); }; //实现点击函数 function attachEvent(src, cb) { $(src).unbind(); var isTouchDevice = 'ontouchstart' in window || navigator.msMaxTouchPoints; if (isTouchDevice) { $(src).bind("touchstart", function(event) { $(this).data("touchon", true); $(this).addClass("pressed"); }); $(src).bind("touchend", function() { $(this).removeClass("pressed"); if ($(this).data("touchon")) { cb.bind(this)(); } $(this).data("touchon", false); }); $(src).bind("touchmove", function() { $(this).data("touchon", false); $(this).removeClass("pressed"); }); } else { $(src).bind("mousedown", function() { $(this).addClass("pressed"); $(this).data("touchon", true); }); $(src).bind("mouseup", function() { $(this).removeClass("pressed"); $(this).data("touchon", false); cb.bind(this)(); }); } }
相关文章推荐
- 移动混合开发之HTML5在移动开发中的准则
- 移动混合开发之HTML5在移动开发中的准则
- 移动开发跨平台之争:本地应用还是HTML5?
- 深度分析HTML5在移动开发方面的发展状况
- 探讨HTML5移动开发的几大特性(必看)
- 移动开发中HTML5能否替代本地程序?
- 浅析:html5移动开发如何使用?
- 移动开发html5最快banner制作(快速生成)有2种方法
- 深度分析HTML5在移动开发方面的发展状况
- HTML5移动开发:手机屏幕分辨率和手机浏览器分辨率
- HTML5移动开发(8)——链接,图片,表格,框架
- HTML5移动开发的几大特性
- html5移动开发对SEO的影响
- HTML5移动开发(9)——从一个多媒体标签说起
- 快速入门系列--MVC--07与HTML5移动开发的结合
- 支付宝“技术风云会”:HTML5引发的移动开发变革
- html5可以为移动开发提供什么
- HTML5移动开发(1)——HTML介绍
- Html5移动开发(2)rem使用和基本布局
- html5移动开发入门资料