移动WEB开发常用技巧
Meta设置
<!-- 设备宽度、禁止缩放 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <!-- 是否删除苹果工具栏和菜单栏(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设置
<!-- 启动图标 -->
<!-- rel添加 -precomposed 后缀表示不添加IOS高光特效 -->
<link rel="apple-touch-icon" href="icon.png">
<link rel="apple-touch-icon-precomposed" href="icon.png">
<!-- iPhone non-retina icon (iOS < 7) -->
<link rel="apple-touch-icon" href="icon.png" sizes="57x57"> <!-- iPad non-retina icon (iOS < 7) -->
<link rel="apple-touch-icon" href="icon.png" sizes="72x72"> <!-- iPad non-retina icon -->
<link rel="apple-touch-icon" href="icon.png" sizes="76x76"> <!-- iPhone retina icon (iOS < 7) -->
<link rel="apple-touch-icon" href="icon.png" sizes="114x114"> <!-- iPhone 6 Plus icon -->
<link rel="apple-touch-icon" href="icon.png" sizes="120x120"> <!-- iPad retina icon (iOS < 7) -->
<link rel="apple-touch-icon" href="icon.png" sizes="144x144"> <!-- iPad retina icon -->
<link rel="apple-touch-icon" href="icon.png" sizes="152x152"> <!-- apple-touch-startup-image 启动画面 -->
<link rel="apple-touch-startup-image" href="/startup.png"> <!-- iPhone -->
<link href="320x460.png" media="(device-width: 320px)" rel="apple-touch-startup-image" /> <!-- iPhone Retina -->
<link href="640x920.png" media="(device-width: 320px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image" /> <!-- iPad retina portrait -->
<link href="1536x2008.png" media="(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" rel="apple-touch-startup-image"> <!-- iPad retina landscape -->
<link href="1496x2048.png" media="(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" rel="apple-touch-startup-image"> <!-- iPad portrait -->
<link href="768x1004.png" media="(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 1) and (orientation: portrait)" rel="apple-touch-startup-image">
<!-- iPad landscape -->
<link href="748x1024.png" media="(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 1) and (orientation: landscape)" rel="apple-touch-startup-image"> <!-- iPhone 6 Plus portrait -->
<link href="1242x2148.png" media="(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" rel="apple-touch-startup-image"> <!-- iPhone 6 Plus landscape -->
<link href="1182x2208.png" media="(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" rel="apple-touch-startup-image"> <!-- iPhone 6 -->
<link href="750x1294.png" media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image"> <!-- iPhone 5 -->
<link href="640x1096.png" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image"> <!-- iPhone < 5 retina -->
<link href="640x920.png" media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image"> <!-- iPhone < 5 -->
<link href="320x460.png" media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 1)" 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-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开发常用技巧的更多相关文章
- web开发常用图片格式
web开发常用图片格式有:gif jpg/jpeg png gif:图片压缩率高,可以显示动画,但是只能显示256色,可能造成颜色丢失. jpg:图片压缩率高(有损压缩),可以用小文件来显示 ...
- 移动Web开发小技巧
移动Web开发小技巧 添加到主屏后的标题(IOS) name="apple-mobile-web-app-title" content="标题"> 启用 ...
- HTML5-移动开发常用技巧与弹性布局的使用
一.移动开发常用技巧 Viewport基本知识 设置布局Viewport的各种信息 1.width=device-width: 设置Viewport视口宽度等于设备宽度 2.initial-scale ...
- iOS开发--常用技巧 (MJRefresh详解)
iOS开发--常用技巧 (MJRefresh详解) https://github.com/CoderMJLee/MJRefresh 下拉刷新01-默认 self.tableView.head ...
- 我在ubuntu桌面系统下进行WEB开发常用的软件
公司电脑本来是win系统的,不知道怎么突然中毒了,由于比较讨厌杀毒软件,所以之前都被我卸载掉了,所以我干脆重装了一个ubuntu系统 1.IDE vscode 各种插件,自带Git,markdo ...
- Nodejs WEB开发常用库和框架
我在Nodejs的体系里也算泡了很久了,的确非常喜欢javascript和Nodejs. 在我看来,用nodejs做web开发有以下几个优点: Javascript作为一个语法异常简单的脚本语言,约束 ...
- web 开发常用字符串表达式匹配
记录一下 web 开发中常用的一些字符串模式,这是我遇到的一些,后面如果还有的话,欢迎大神提出,会继续更新. 正则表达式 这个主要用在前端的验证,nginx 路径匹配,shell 脚本文本处理,后端感 ...
- 【干货分享】sketch 前端开发常用技巧总结
sketch横空出世,移动端的应用越来越多的采用sketch来做,前端开发也需要掌握更多sketch技巧. (1) sketch导出图片时,如何快速选择多个图层? 1. 在画布上任一点单击并拖拽出一个 ...
- Sublime Text 3 web 开发常用配置
前沿 Sublime Text 是一个代码编辑器(Sublime Text 2是收费软件,但可以无限期试用),也是HTML和散文先进的文本编辑器.Sublime Text是由程序员Jon Skinne ...
随机推荐
- ROBOTS.TXT屏蔽笔记、代码、示例大全
自己网站的ROBOTS.TXT屏蔽的记录,以及一些代码和示例: 屏蔽后台目录,为了安全,做双层管理后台目录/a/xxxx/,蜘蛛屏蔽/a/,既不透露后台路径,也屏蔽蜘蛛爬后台目录 缓存,阻止蜘蛛爬静态 ...
- ubuntu下安装pyqt5
在网上看了很多ubuntu系统中安装pyqt5,感觉有些麻烦. 主要的库只有一个:python3-pyqt5 可通过新立得安装,也可通过shell命令安装 sudo apt-get install p ...
- Linux下的管道命令有这些:
Linux下的管道命令有这些: 选取命令:cat grep 排序命令:sort wc uniq 双向重定向:tee 字符转换命令: tr, col, join, paste, expand 切割命令: ...
- 关于uC/OS的简单学习(转)
1.微内核 与Linux的首要区别是,它是一个微内核,内核所实现的功能非常简单,主要包括: 一些通用函数,如TaskCreate(),OSMutexPend(),OSQPost()等. 中断处理函数, ...
- SSH三者作用
Struts在项目中的作用 Struts 在项目主要起控制作用,只要用于web层(即视图层和控制层)Struts本身是使用典型的MVC结构实现的,项目中使用了struts之后就等于项目也是一个MVC结 ...
- 设置iOS项目BuildVersion自动增加-备用
一.概念阐述:Build与Version的区别 在iOS中有两种“版本号”,也就是所谓的version号与build号,如下图所示: 我们用最简洁的语言来区分这两个版本号的区别以及用途如下: Vers ...
- Unity中Mecanim工作流
Mecanim工作流可以被分解为3个主要阶段:1.资源的准备和导入这一阶段由美术师或动画师通过第三方工具来完成,例如Max或Maya.2.角色的建立主要有以下两种方式1)人形角色的建立.Mecanim ...
- op+3g
https://forum.openwrt.org/viewtopic.php?id=44895 http://eko.one.pl/forum/viewtopic.php?id=10269 http ...
- bzoj2325 [ZJOI2011]道馆之战
Description 口袋妖怪(又名神奇宝贝或宠物小精灵)红/蓝/绿宝石中的水系道馆需要经过三个冰地才能到达馆主的面前,冰地中的每一个冰块都只能经过一次.当一个冰地上的所有冰块都被经过之后,到下一个 ...
- C# 实现MD5 Hash 计算
C#提供了一系列的加密库,可以让我们自由使用,这里我来介绍如何使用C#的加密库实现MD5 hash值的计算工作. 参考代码: private static String CalcMd5(String ...