移动web前端开发,页面局部滑动之iscroll框架
2012-08-19 21:55
567 查看
先看个简单的,移动设备上,横向滑动内容块的例子:
此段代码可以实现,在移动设备上,横向滑动内容块的效果。
关于iscroll的参数浅析,实际中一些兼容问题,在下次文章中来学习。
<head> <style> body,ul,li { padding:10px; margin:0; } body { font-size:12px; -webkit-user-select:none; -webkit-text-size-adjust:none; font-family:helvetica; } #wrapper { width:300px; height:160px; float:left; position:relative; /* On older OS versions "position" and "z-index" must be defined, */ z-index:1; /* it seems that recent webkit is less picky and works anyway. */ overflow:hidden; background:#aaa; -webkit-border-radius:10px; -moz-border-radius:10px; -o-border-radius:10px; border-radius:10px; background:#e3e3e3; } #scroller { width:2100px; height:100%; float:left; padding:0; } #scroller ul { list-style:none; display:block; float:left; width:100%; height:100%; padding:0; margin:0; text-align:left; } #scroller li { -webkit-box-sizing:border-box; -moz-box-sizing:border-box; -o-box-sizing:border-box; box-sizing:border-box; display:block; float:left; width:300px; height:160px; text-align:center; font-family:georgia; font-size:18px; line-height:140%; } </style> <script src="iscroll.js"></script> <script> var myscroll; function loaded() { myScroll = new iScroll('wrapper', { snap: true, hScrollbar: false}); } document.addEventListener("DOMContentLoaded",loaded,false); </script> </head> <body> <div id="wrapper"> <div id="scroller"> <ul> <li><img src="images/1.jpg"></li> <li><em>A robot must obey any orders given to it by human beings, except where such orders would conflict with the First Law.</em></li> <li><img src="images/2.gif"></li> <li><em>A robot may not harm humanity, or, by inaction, allow humanity to come to harm.</em></li> <li><img src="images/3.gif"></li> </ul> </div> </div> </body>
此段代码可以实现,在移动设备上,横向滑动内容块的效果。
关于iscroll的参数浅析,实际中一些兼容问题,在下次文章中来学习。
相关文章推荐
- 移动web页面前端开发总结
- 移动web页面前端开发总结
- 移动web页面前端开发总结
- 移动web页面前端开发总结
- 移动web页面前端开发总结
- 移动web页面前端开发总结
- 移动web前端开发研究(jquery mobile 框架)
- web移动前端页面,jquery判断页面滑动方向
- 移动前端开发中添加一些webkit专属的HTML5头部标签,帮助浏览器更好解析html代码,更好地将移动web前端页面表现出来。本文整理一些常用的meta标签
- 12款很赞的web前端移动开发框架
- 我的第一个python web开发框架(7)——本地部署前端访问服务器
- (转)基于MVC4+EasyUI的Web开发框架经验总结(6)--在页面中应用下拉列表的处理
- 移动设备web开发插件iScroll的使用详解
- 移动平台WEB前端开发技巧汇总
- 移动平台WEB前端开发技巧汇总
- clojure实战——搭建web前端开发框架(模拟web服务器、推送js修改)
- 基于Metronic的Bootstrap开发框架经验总结(9)--实现Web页面内容的打印预览和保存操作
- Android学习 - 移动web开发框架
- 10大优秀的移动Web应用程序开发框架推荐
- 基于MVC4+EasyUI的Web开发框架经验总结(6)--在页面中应用下拉列表的处理