easy Html5 - Jquery Mobile之ToolBars(Header and Footer)
jquery 在web js框架上的风暴还在继续却也随着移动终端走向了mobile;那么jquery mobile到底包括些什么呢
简介
工具栏是在移动网站和应用中的头部,尾部或者内容中的工具条;Jquery Mobile提供了一套标准的工具和导航栏的工具,可以在绝大多数情况下直接使用;头部一般做网站或应用的标题,功能导航等,一般都是些文字或者按钮;尾部是一个页面的最下端,内容可以根据具体应用需要来排版,也可以放功能导航、各种链接等;内容中使用一般是作为功能的展示,显示内容同时附带着功能;jquery mobile还提供了这些工具栏的一些特性即工具栏定位;通过设置工具栏定位,可以使工具栏一直处于头部或者底部,当滚动时,如果工具栏被滚动到屏幕之外,jquery mobile会自动动画过度将工具条重新显示到头部或者底部;而且任何时候,当点击定位了的工具栏时,点击屏幕会让工具栏消失,再点击时会重新显示;当然还支持全屏的定位模式,当工具条被滚动到屏幕之外时,不会立即显示滚动条,而是当点击屏幕时,工具条会自动显示在固定的位置上。
Header
1.页面Header是一个data-role为header的div,当然我们可以在这个div里定义其他任何内容,比如常用的后退按钮等;
<div data-role="header" data-theme="c">
<h1>Page Header</h1>
</div><!-- /header -->
2.一般在header里添加的button不要太多,添加在header里的按钮带有自动定位功能;
比如当添加一个按钮时:
<div data-role="header" data-theme="c" data-position="fixed">
<h1>Page Header</h1>
<!-- <a href="../index.htm" data-icon="back">back</a>-->
<a href="../index.htm" data-icon="check">Save</a>
<!-- <a href="../index.htm" class="ui-btn-left" data-icon="back">back1</a>
<a href="../index.htm" data-icon="check">Save1</a>-->
</div><!-- /header -->

添加两个按钮时:
<div data-role="header" data-theme="c" data-position="fixed">
<h1>Page Header</h1>
<a href="../index.htm" data-icon="back">back</a>
<a href="../index.htm" data-icon="check">Save</a>
<!-- <a href="../index.htm" class="ui-btn-left" data-icon="back">back1</a>
<a href="../index.htm" data-icon="check">Save1</a>-->
</div><!-- /header -->

更多按钮时:
<div data-role="header" data-theme="c" data-position="fixed">
<h1>Page Header</h1>
<a href="../index.htm" data-icon="back">back</a>
<a href="../index.htm" data-icon="check">Save</a>
<a href="../index.htm" class="ui-btn-left" data-icon="back">back1</a>
<a href="../index.htm" data-icon="check">Save1</a>
</div><!-- /header -->

自动定位功能实际是当header内容之有一个按钮时,会自动给这个按钮添加ui-btn-left样式,当有两个时会给前面一个添加ui-btn-left样式,给第二个自动添加ui-btn-right样式;更多时,第三个到第n个应用ui-btn样式;
当然我们可以自己设置按钮的位置:
<div data-role="header" data-theme="c" data-position="fixed">
<h1>Page Header</h1>
<!-- <a href="../index.htm" data-icon="back">back</a>-->
<a href="../index.htm" class="ui-btn-right" data-icon="check">Save</a>
<!-- <a href="../index.htm" class="ui-btn-left" data-icon="back">back1</a>
<a href="../index.htm" data-icon="check">Save1</a>-->
</div><!-- /header -->

当然毕竟header只是一个div,当然我们可以接着在这个div里放任何内容,只要你愿意;
3.固定header的位置;
当我们在做app时,页面显示更多内容,当然会首选滚动条,但是大家都会知道仅在中部内容上添加滚动条;那么我们的web站点或应用呢;我们也希望在滚动内容时,头和脚固定位置不动;这个jquery mobile通过header或者footer的data-position来设置的;默认的data-position是inline,即你不设置data-position属性,或者设置data-posiiton=”inline”时,页面头和脚会跟随者页面的滚动条滚动;当设置data-posiiton为fixed时,头和脚就会悬浮起来,当内容滚动时,头和脚也会跟着滚动,但是位置一直在最上方和最下方;


这个很简单只需要给header和footer添加data-position="fixed"就ok了
<div id="mainPage" data-role="page" data-add-back-btn="true">
<div data-role="header" data-theme="c" data-position="fixed">
<h1>Page Header</h1>
<a href="../index.htm" data-icon="back">back</a>
<a href="../index.htm" class="ui-btn-right" data-icon="check">Save</a>
<!-- <a href="../index.htm" class="ui-btn-left" data-icon="back">back1</a>
<a href="../index.htm" data-icon="check">Save1</a>-->
</div><!-- /header -->
<div data-role="content">
<h3>About us</h3>
In browsers that support CSS position: fixed (most desktop browsers, iOS5+, Android 2.2+, BlackBerry 6, and others), toolbars that use the "fixedtoolbar" plugin will be fixed to the top or bottom of the viewport, while the page content scrolls freely in between. In browsers that don't support fixed positioning, the toolbars will remain positioned in flow, at the top or bottom of the page.
To enable this behavior on a header or footer, add the data-position="fixed" attribute to a jQuery Mobile header or footer element.
Fullscreen fixed toolbars sit on top of the content at all times when they are visible, and unlike regular fixed toolbars, fullscreen toolbars do not fall back to static positioning when toggled. Instead they disappear from the screen entirely. Fullscreen toolbars are ideal for more immersive interfaces, like a photo viewer that is meant to fill the entire screen with the photo itself and no distractions.
To enable this option on a fixed header or footer, add the data-fullscreen attribute to the element.
</div><!-- /content -->
<div data-role="footer" data-position="fixed">
<h4>Page Fotter</h4>
</div><!-- /footer -->
</div><!-- /page -->
Footer
1.footer和header一样,也是一个带有data-role=footer的div容器;拥有和header一样的data-position属性;这里就不在多讲了;
2.区别的是,footer不会有header那样的里面的按钮会有自动定位功能;footer里的内容会按照具体的css样式来显示内容;
3.当然我们可以再footer里添加各种自定义的功能(因为它只是一个div么 :) );
4.有些情况下我们也会需要一个尾部栏为全局导航元素,希望页面切换时尾部栏也固定并显示,创造一个持续的尾部栏可以做到这一点;给尾部栏添加data-id属性,并且在所有关联的页面的尾部栏设定同样的data-id的值,就可以使尾部栏在页面切换时也固定并显示;
easy Html5 - Jquery Mobile之ToolBars(Header and Footer)的更多相关文章
- Android+Jquery Mobile学习系列(2)-HTML5/Jquery Mobile基础
本章介绍两个关键字[HTML5]和[Jquery Mobile],简单说这两者的关系是:HTML5作为主体,Jquery Mobile在HTML5的基础上对其进行了优化.装饰. HTML5 HTML5 ...
- html5文章 -- 使用 jQuery Mobile 与 HTML5 开发 Web App —— jQuery Mobile 基础
这篇文章是使用 jQuery Mobile 与 HTML5 开发 Web App 系列的第二篇,在本文以及接下来的数篇文章 Kayo 将会介绍 jQuery Mobile 的组件.事件响应以及可以调用 ...
- 用jQuery Mobile做HTML5移动应用的三个优缺点
JQuery Mobile 和 HTML5 的 3个优点 1. 上手迅速并支持快速迭代:在一个星期多一点的时间里,通过阅读JQuery Mobile文档以及O’Reilly出版的JQuery Mobi ...
- 使用 jQuery Mobile 与 HTML5 开发 Web App 系列文章目录
使用 jQuery Mobile 与 HTML5 开发 Web App 系列文章目录 时间:2012年9月20日 分类:JavaScript 标签:HTML5‚ jQuery Mobile‚ Web ...
- jquery mobile demo
<!DOCTYPE html> <html> <head> <title>jQuery Mobile Demo</title> <me ...
- Android+Jquery Mobile学习系列-目录
最近在研究学习基于Android的移动应用开发,准备给家里人做一个应用程序用用.向公司手机移动团队咨询了下,觉得使用Android的WebView上手最快,因为WebView等于是一个内置浏览器,可以 ...
- jQuery Mobile + HTML5
最近项目需要,需要构建一个适合手持设备访问的站点,作者从网上查阅了一些资料,本文就是基于此而来. 首先下载jQuery Mobile http://jquerymobile.com/,选择稳定版即可. ...
- [转]使用 jQuery Mobile 与 HTML5 开发 Web App —— jQuery Mobile 事件详解
在前文<使用 jQuery Mobile 与 HTML5 开发 Web App —— jQuery Mobile 默认配置与事件基础>中,Kayo 对 jQuery Mobile 事件的基 ...
- HTML5+JS手机web开发之jQuery Mobile初涉
一.起始之语 我一直都是在PC上折腾网页的,这会儿怎么风向周边捣鼓起手机网页开发呢?原因是公司原先使用Java开发的产品,耗了不少人力财力,但是最后的效果却不怎么好.因为,Android系统一套东西, ...
随机推荐
- T-SQL:SQL Server-数据库查询语句基本查询
ylbtech-SQL Server-Basic:SQL Server-数据库查询语句基本查询 SQL Server 数据库查询语句基本查询. 1,数据库查询语句基本查询 数据库 SQL Serv ...
- JAVA多线程一
介绍 线程是操作系统的最小单位,一个进程可以创建多个线程. 线程有五种状态,分别是新建.就绪.运行.阻塞.死亡状态. 多线程可以提高执行效率,但是如果单线程可以完成的任务,使用多线程反而会增加不必要的 ...
- Golang官方图片库
Golang 的图片出来通过提供操作每一个像素点设置颜色(http://www.cnblogs.com/ghj1976/p/3441536.html) 和 提供通过可选蒙版图片重叠操作 (http:/ ...
- <测试用例设计>用户及权限管理功能常规测试方法
1) 赋予一个人员相应的权限后,在界面上看此人员是否具有此权限,并以此人员身份登陆,验证权限设置是否正确(能否超出所给予的权限): 2) 删除或修改已经登陆系统并正在进行操作的人员的权限,程序能否 ...
- Android百度地图开发(三)范围搜索
// 1.新建项目 将地图API添加进classpath中: 2.在activity_main.xml中添加一个MapView,用来显示地图: <LinearLayout xmlns:andro ...
- Wireshark基本介绍及应用tcp
wireshark介绍 wireshark的官方下载网站: http://www.wireshark.org/ wireshark是非常流行的网络封包分析软件,功能十分强大.可以截取各种网络封包,显示 ...
- 在VS2103环境中集成Doxygen工具
自己已将学习了两三次了吧,差不多这次该总结一下: Doxygen是一种开源跨平台的,以类似JavaDoc风格描述的文档系统,完全支持C.C++.Java.Objective-C和IDL语言,部分支持P ...
- SpringMVC + Spring + MyBatis 学习笔记:提交数据遭遇基础类型和日期类型报400错误解决方法
系统:WIN8.1 数据库:Oracle 11GR2 开发工具:MyEclipse 8.6 框架:Spring3.2.9.SpringMVC3.2.9.MyBatis3.2.8 使用SpringMVC ...
- Shell script之if...then
1 Variable in shell If you want to print variable, then use echo command. In front of the variable ...
- Vi的基本使用方法
转载自http://linux.chinaunix.net/doc/office/2005-01-24/898.shtml vi编辑器是所有Unix及Linux系统下标准的编辑器,它的强大不逊色于任何 ...