码迷,mamicode.com
首页 > 移动开发 > 详细

移动WEB开发常用技巧(转)

时间:2015-01-05 11:07:11      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:

Meta设置

技术分享
<!-- 设备宽度、禁止缩放 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" />

<!-- 是否删除苹果工具栏和菜单栏(yes/no) -->
<meta name="apple-mobile-web-app-capable" content="yes" />

<!-- 苹果顶部导航栏颜色(default/black/black-translucent) -->
<meta name="apple-mobile-web-app-status-bar-style" content="black" />

<!-- 忽略识别电话号码 -->
<meta name="format-detection" content="telephone=no" />

<!-- 忽略识别邮箱 -->
<meta name="format-detection" content="email=no" />

<!-- 启用360浏览器的极速模式(webkit) -->
<meta name="renderer" content="webkit">

<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑莓 -->
<meta name="HandheldFriendly" content="true">

<!-- 微软的老式浏览器 -->
<meta name="MobileOptimized" content="320">

<!-- uc强制竖屏 -->
<meta name="screen-orientation" content="portrait">

<!-- QQ强制竖屏 -->
<meta name="x5-orientation" content="portrait">

<!-- UC强制全屏 -->
<meta name="full-screen" content="yes">

<!-- QQ强制全屏 -->
<meta name="x5-fullscreen" content="true">

<!-- UC应用模式 -->
<meta name="browsermode" content="application">

<!-- QQ应用模式 -->
<meta name="x5-page-mode" content="app">

<!-- windows phone 点击无高光 -->
<meta name="msapplication-tap-highlight" content="no">
技术分享

Link设置

技术分享
<!-- icon,-precomposed.png为后缀的ios7不添加特效 -->
<link rel="apple-touch-icon" href="touch-icon-iphone.png"> <!-- 默认大小60*60 -->
<link rel="apple-touch-icon" sizes="76x76" href="touch-icon-ipad.png">
<link rel="apple-touch-icon" sizes="120x120" href="touch-icon-iphone-retina.png">
<link rel="apple-touch-icon" sizes="152x152" href="touch-icon-ipad-retina.png">

<!-- apple-touch-startup-image 启动画面 -->
<link rel="apple-touch-startup-image" href="/startup.png">
<!-- iPhone --> <link href="apple-touch-startup-image-320x460.png" media="(device-width: 320px)" rel="apple-touch-startup-image" /> <!-- iPhone Retina --> <link href="apple-touch-startup-image-640x920.png" media="(device-width: 320px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image" />
<!-- iPhone 5 --> <link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)" href="apple-touch-startup-image-640x1096.png">
<!-- iPad portrait --> <link href="apple-touch-startup-image-768x1004.png" media="(device-width: 768px) and (orientation: portrait)" rel="apple-touch-startup-image" />
<!-- iPad landscape --> <link href="apple-touch-startup-image-748x1024.png" media="(device-width: 768px) and (orientation: landscape)" rel="apple-touch-startup-image" />
<!-- iPad Retina portrait --> <link href="apple-touch-startup-image-1536x2008.png" media="(device-width: 1536px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image" />
<!-- iPad Retina landscape --> <link href="apple-touch-startup-image-1496x2048.png"media="(device-width: 1536px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2)"rel="apple-touch-startup-image" />
技术分享

电话/短信/Email/Android/GPS

技术分享
<!-- 电话 -->
<a href="tel:10086">打电话</a>
<a href="wtai://wp/mc;10086">打电话</a>
<span onclick="location.href=‘tel:10086‘">打电话</span>

<!-- 短信 -->
<a href="sms:10086">发短信</a>
<a href="sms:10086?body=内容">发短信</a>
<a href="sms:10086,10010?body=内容">发短信</a>

<!-- Email -->
<a href="mailto:a@qq.com">发邮件</a>
<a href="mailto:a@qq.com,b@qq.com">发邮件</a>
<a href="mailto:a@qq.com?subject=标题">发邮件</a>
<a href="mailto:a@qq.com?subject=标题 mailto&cc=b@qq.com">发邮件</a>

<!-- 安卓市场-->
<a href="market://search?q=MyApp">MyApp</a>

<!-- GPS -->
<a href="geopoint:经度,纬度">我的位置</a>
技术分享

样式设置

技术分享
<!-- 设置开始页面图片 -->
<link rel=”apple-touch-startup-image” href=”startup.png” />

<!-- 在设置书签的时候可以显示好看的图标 -->
<link rel=”apple-touch-icon” href=”iphon_tetris_icon.png”/>

<!--  肖像模式样式 -->
<link rel="stylesheet" media="all and (orientation:portrait)" href="portrait.css" />

<!-- 风景模式样式 -->
<link rel="stylesheet" media="all and (orientation:landscape)" href="landscape.css" /> 

<!-- 竖屏时使用的样式 -->
<style media="all and (orientation:portrait)"></style> 

<!-- 横屏时使用的样式 -->
<style media="all and (orientation:landscape)"></style> 
技术分享

app是否从主屏启动

// IOS
if( navigator.standalone === true ){}

关闭IOS键盘自动大写

autocapitalize="off"

IOS禁止弹出菜单(长按a标签)/复制图片

/* IOS */
-webkit-touch-callout: none;

IOS禁止用户选中文字

/* IOS */
-webkit-user-select: none;

IOS中获取滚动条距离

window.scrollX、window.scrollY

解决盒子边框溢出

-webkit-box-sizing: border-box;

阻止旋转屏幕时字体大小自动调整

-webkit-text-size-adjust:none;

去除Android里a标签边框 

-webkit-tap-highlight-color: rgba(0, 0, 0, 0);

设备像素比(设备物理像素/设备独立像素)

if ( window.devicePixelRatio == 1) {}

去除浏览器地址栏

window.onload = function(){
   window.setTimeout(scrollTo, 0, 0, 0); 
};

阻止页面整体滚动

document.body.addEventListener(‘touchmove‘, function(ev) {  
  ev.preventDefault();  
}, false); 

伪类 :active 生效

// touchstart或touchend
document.addEventListener(‘touchstart‘,function(){},false);

去除IE10里input关闭图标

input:-ms-clear { display:none; }

Date支持placeholder

<input placeholder="Date" type="text" onfocus="(this.type=‘date‘)"> 

 

移动WEB开发常用技巧(转)

标签:

原文地址:http://www.cnblogs.com/dylanblog/p/4202958.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!