日期:2014-05-17  浏览次数:20656 次

JQuery Mobile 移动设备上网页开发总结
经过一个半月的摸索,JQuery Mobile移动设备上网页开发总算告一段落了, 版本已发布出去了,感觉不是很完美,现在总结一下,有类似运用的朋友可以交流一下,希望能够起到抛砖引玉的效果


1.官方DEMO地址: http://jquerymobile.com/

2.官方论坛地址: http://forum.jquery.com/

3.开发过程中遇到的问题示例:
3.1 主题(data-theme)的问题
    jquery mobile的主题有下面几种
    data-theme="a"
    data-theme="b"
    data-theme="c"
    data-theme="d"
    data-theme="e"
各种主题的效果请参考:http://jquerymobile.com/demos/1.0b2/#/demos/1.0b2/docs/pages/pages-themes.html
当然一般开发的时候,不会都用默认的jquery mobile风格的主题,通常要用公司风格的主题样式,下面是我扩展jquery mobile的主题,我从z开始,可以从官方的主题css样式拷贝一份改改:

//jqm-theme-extend.css
/* Z 一级标题样式
-----------------------------------------------------------------------*/

.ui-bar-z {
	border-top: 			1px solid 		#33CC42;
	border-right: 			0;
	border-bottom: 			1px solid 		#1D7425;
	border-left: 			0;
	background: 			#004000;
	color: 					#fff;
	font-weight: bold;
	line-height: 1.4;
        //背景色渐变效果
	background-image: -moz-linear-gradient(top, 
							#33CC42, 
							#1D7425);
	background-image: -webkit-gradient(linear,left top,left bottom,
		color-stop(0, 		#33CC42),
		color-stop(1, 		#1D7425));
	-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#049000', EndColorStr='#03b108')";
}
.ui-bar-z,
.ui-bar-z input,
.ui-bar-z select,
.ui-bar-z textarea,
.ui-bar-z button {
	font-family: Helvetica, Arial, sans-serif;
}
.ui-bar-z .ui-link-inherit {
	color: 					#fff;
}
.ui-bar-z .ui-link {
	color: 					#7cc4e7;
	font-weight: bold;
}

.ui-body-z {
	border: 1px solid 		#C6C6C6;
	background: 			#cccccc;
	color: 					#333333;
	font-weight: normal;
	line-height: 1.4;
	background-image: -moz-linear-gradient(top, 
							#e6e6e6, 
							#cccccc);
	background-image: -webkit-gradient(linear,left top,left bottom,
		color-stop(0, 		#e6e6e6),
		color-stop(1, 		#cccccc));
	 -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#e6e6e6', EndColorStr='#cccccc')";
}
.ui-body-z,
.ui-body-z input,
.ui-body-z select,
.ui-body-z textarea,
.ui-body-z button {
	font-family: Helvetica, Arial, sans-serif;
}
.ui-body-z .ui-link-inherit {
	color: 					#333333;
}
.ui-body-z .ui-link {
	color: 					#2489CE;
	font-weight: bold;
}
.ui-btn-up-z {
	border: 1px solid 		#049000;
	background: 			#049000;
	font-weight: bold;
	color: 					#fff;
        //去除背景色渐变效果	
        /* 
	background-image: -moz-linear-gradient(top, 
							#049000, 
							#049000);
	background-image: -webkit-gradient(linear,left top,left bottom,
			color-stop(0, 	#049000),
			color-stop(1, 	#049000));
	-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#049000', EndColorStr='#049000')";
	 */
}
.ui-btn-up-z a.ui-link-inherit {
	color: 					#fff;
}
.ui-btn-hover-z {
	border: 1px solid 		#74C138;
	background: 			#33CC42;
	font-weight: bold;
	color: 					#fff;
	/*
	background-image: -moz-linear-gradient(top, 
							#74C138, 
							#74C138);
	background-image: -webkit-gradient(linear,left top,left bottom,
			color-stop(0, 	#74C138),
			color-stop(1, 	#74C138));
	-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#74C138', EndColorStr='#74C138')";
	*/
}
.ui-btn-hover-z a.ui-link-inherit {
	color: 					#fff;
}
.ui-btn-down-z {
	border: 1px solid 		#03B108;
	background: 			#03B108;
	font-weight: bold;
	color: 					#ffffff;
	/*
	background-image: -moz-linear-gradient(top, 
							#03B108, 
							#03B108);
	background-image: -webkit-gradient(linear,left top,left bottom,
		color-stop(0, 		#03B108),
		color-stop(1, 		#03B108));
	-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#03B108', EndColorStr='#03B108')";
	*/
}
.ui-btn-down-z a.ui-link-inherit {
	color: 					#fff;
}
.ui-btn-up-z,
.ui-bt