工作了有一段时间,基本上都在搞移动端的前端开发,工作的过程中遇到过很多问题,bug的解决方案,记录下来,以便后用!!!内容并不是很全,以后每遇到一个问题都会总结在这里,分享给大家!

一、meta标签相关知识

1、移动端页面设置视口宽度等于设备宽度,并禁止缩放。

<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />

2、移动端页面设置视口宽度等于定宽(如640px),并禁止缩放,常用于微信浏览器页面。

<meta name="viewport" content="width=640,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />

3、禁止将页面中的数字识别为电话号码

<meta name="format-detection" content="telephone=no" />

4、忽略Android平台中对邮箱地址的识别

<meta name="format-detection" content="email=no" />

5、当网站添加到主屏幕快速启动方式,可隐藏地址栏,仅针对iossafari

<meta name="apple-mobile-web-app-capable" content="yes" />

<!-- ios7.0版本以后,safari上已看不到效果 -->

6、将网站添加到主屏幕快速启动方式,仅针对iossafari顶端状态条的样式

<meta name="apple-mobile-web-app-status-bar-style" content="black" />

<!-- 可选default、black、black-translucent -->

viewport模板

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">

<meta content="yes" name="apple-mobile-web-app-capable">

<meta content="black" name="apple-mobile-web-app-status-bar-style">

<meta content="telephone=no" name="format-detection">

<meta content="email=no" name="format-detection">

<title>title</title>

<link rel="stylesheet" href="index.css">

</head>

<body>

content...

</body>

</html>

二、CSS样式技巧

1、禁止iosandroid用户选中文字

.css{-webkit-user-select:none}

2、禁止ios长按时触发系统的菜单,禁止ios&android长按时下载图片

.css{-webkit-touch-callout: none}

3webkit去除表单元素的默认样式

.css{-webkit-appearance:none;}

4、修改webkit表单输入框placeholder的样式

input::-webkit-input-placeholder{color:#AAAAAA;}

input:focus::-webkit-input-placeholder{color:#EEEEEE;}

5、去除android a/button/input标签被点击时产生的边框 & 去除ios a标签被点击时产生的半透明灰色背景

a,button,input{-webkit-tap-highlight-color:rgba(255,0,0,0);}

6ios使用-webkit-text-size-adjust禁止调整字体大小

body{-webkit-text-size-adjust: 100%!important;}

7android 上去掉语音输入按钮

input::-webkit-input-speech-button {display: none}

8、移动端定义字体,移动端没有微软雅黑字体

/* 移动端定义字体的代码 */

body{font-family:Helvetica;}

三、其他技巧

1、手机拍照和上传图片

<!-- 选择照片 -->

<input type=file accept="image/*">

<!-- 选择视频 -->

<input type=file accept="video/*">

2、取消inputios下,输入的时候英文首字母的默认大写

<input autocapitalize="off" autocorrect="off" />

3、打电话和发短信

<a href="tel:0755-10086">打电话给:0755-10086</a>

<a href="sms:10086">发短信给: 10086</a>

四、CSS reset

/* hcysun  */

@charset "utf-8";

/* reset */

html{

-webkit-text-size-adjust:none;

-webkit-user-select:none;

-webkit-touch-callout: none

font-family: Helvetica;

}

body{font-size:12px;}

body,h1,h2,h3,h4,h5,h6,p,dl,dd,ul,ol,pre,form,input,textarea,th,td,select{margin:0; padding:0; font-weight: normal;text-indent: 0;}

a,button,input,textarea,select{ background: none; -webkit-tap-highlight-color:rgba(255,0,0,0); outline:none; -webkit-appearance:none;}

em{font-style:normal}

li{list-style:none}

a{text-decoration:none;}

img{border:none; vertical-align:top;}

table{border-collapse:collapse;}

textarea{ resize:none; overflow:auto;}

/* end reset */

五、常用公用CSS style

/* public */

/* 清除浮动 */

.clear { zoom:1; }

.clear:after { content:''; display:block; clear:both; }

/* 定义盒模型为怪异和模型(宽高不受边框影响) */

.boxSiz{

-webkit-box-sizing: border-box;

-moz-box-sizing: border-box;

-ms-box-sizing: border-box;

-o-box-sizing: border-box;

box-sizing: border-box;

}

/* 强制换行 */

.toWrap{

word-break: break-all;       /* 只对英文起作用,以字母作为换行依据。 */

word-wrap: break-word;      /* 只对英文起作用,以单词作为换行依据。*/

white-space: pre-wrap;     /* 只对中文起作用,强制换行。*/

}

/* 禁止换行 */

.noWrap{

white-space:nowrap;

}

/* 禁止换行,超出省略号 */

.noWrapEllipsis{

white-space:nowrap; overflow:hidden; text-overflow:ellipsis;

}

/* 文字两端对齐 */

.text-justify{

text-align:justify;

text-justify:inter-ideograph;

}

/* 定义盒模型为 flex布局兼容写法并让内容水平垂直居中 */

.flex-center{

display: -webkit-box;

display: -moz-box;

display: -ms-flexbox;

display: -o-box;

display: box;

-webkit-box-pack: center;

-moz-box-pack: center;

-ms-flex-pack: center;

-o-box-pack: center;

box-pack: center;

-webkit-box-align: center;

-moz-box-align: center;

-ms-flex-align: center;

-o-box-align: center;

box-align: center;

}

/* public end */

六、flex布局

1、定义弹性盒模型兼容写法

/*

box

inline-box

*/

display: -webkit-box;

display: -moz-box;

display: -ms-flexbox;

display: -o-box;

display: box;

2box-orient 定义盒模型内伸缩项目的布局方向

/**

* vertical column  垂直

* horizontal row   水平 默认值

*/

-webkit-box-orient: horizontal;

-moz-box-orient: horizontal;

-ms-flex-direction: row;

-o-box-orient: horizontal;

box-orient: horizontal;

3box-direction 定义盒模型内伸缩项目的正序(normal默认值)、倒叙(reverse)

/* Firefox */

display:-moz-box;

-moz-box-direction:reverse;

/* Safari、Opera 以及 Chrome */

display:-webkit-box;

-webkit-box-direction:reverse;

4box-pack 对盒子水平富裕空间的管理

/*

start

end

center

justify

*/

-webkit-box-pack: center;

-moz-box-pack: center;

-ms-flex-pack: center;

-o-box-pack: center;

box-pack: center;

5box-pack 对盒子垂直方向富裕空间的管理

/*

start

end

center

*/

/* box-align */

-webkit-box-align: center;

-moz-box-align: center;

-ms-flex-align: center;

-o-box-align: center;

box-align: center;

6、定义伸缩项目的具体位置

/*-moz-box-ordinal-group:1;*/ /* Firefox */

/*-webkit-box-ordinal-group:1;*/ /* Safari 和 Chrome */

.box div:nth-of-type(1){-webkit-box-ordinal-group:1;}

.box div:nth-of-type(2){-webkit-box-ordinal-group:2;}

.box div:nth-of-type(3){-webkit-box-ordinal-group:3;}

.box div:nth-of-type(4){-webkit-box-ordinal-group:4;}

.box div:nth-of-type(5){-webkit-box-ordinal-group:5;}

7、定义伸缩项目占空间的份数

-moz-box-flex:2.0; /* Firefox */

-webkit-box-flex:2.0; /* Safari 和 Chrome */

.box div:nth-of-type(1){-webkit-box-flex:1;}

.box div:nth-of-type(2){-webkit-box-flex:2;}

.box div:nth-of-type(3){-webkit-box-flex:3;}

.box div:nth-of-type(4){-webkit-box-flex:4;}

.box div:nth-of-type(5){-webkit-box-flex:5;}

H5移动APP开发 细节详解(转)的更多相关文章

  1. C++的性能C#的产能?! - .Net Native 系列《二》:.NET Native开发流程详解

    之前一文<c++的性能, c#的产能?!鱼和熊掌可以兼得,.NET NATIVE初窥> 获得很多朋友支持和鼓励,也更让我坚定做这项技术的推广者,希望能让更多的朋友了解这项技术,于是先从官方 ...

  2. Extjs MVC开发模式详解

    Extjs MVC开发模式详解   在JS的开发过程中,大规模的JS脚本难以组织和维护,这一直是困扰前端开发人员的头等问题.Extjs为了解决这种问题,在Extjs 4.x版本中引入了MVC开发模式, ...

  3. 当里个当,免费的HTML5连载来了《HTML5网页开发实例详解》连载(一)

    读懂<HTML5网页开发实例详解>这本书 你还在用Flash嘛?帮主早不用了 乔布斯生前在公开信“Flash之我见”中预言:像HTML 5这样在移动时代中创立的新标准,将会在移动设备上获得 ...

  4. Python开发技术详解PDF

    Python开发技术详解(高清版)PDF 百度网盘 链接:https://pan.baidu.com/s/1F5J9mFfHKgwhkC5KuPd0Pw 提取码:xxy3 复制这段内容后打开百度网盘手 ...

  5. ext.js的mvc开发模式详解

    ext.js的mvc开发模式详解和环境配置 在JS的开发过程中,大规模的JS脚本难以组织和维护,这一直是困扰前端开发人员的头等问题.Extjs为了解决这种问题,在Extjs 4.x版本中引入了MVC开 ...

  6. ​ 用一个开发案例详解Oracle临时表

    ​ 用一个开发案例详解Oracle临时表 2016-11-14 bisal ITPUB  一.开发需求  最近有一个开发需求,大致需要先使用主表,或主表和几张子表关联查询出ID(主键)及一些主表字段 ...

  7. 【eclipse插件开发实战】 Eclipse插件开发5——时间插件Timer开发实例详解

    Eclipse插件开发5--时间插件Timer开发实例详解 这里做的TimeHelper插件设定为在菜单栏.工具栏提供快捷方式,需要在相应地方设置扩展点,最后弹出窗体显示时间. 在上一篇文章里创建好了 ...

  8. iOS开发-Runtime详解

    iOS开发-Runtime详解 简介 Runtime 又叫运行时,是一套底层的 C 语言 API,其为 iOS 内部的核心之一,我们平时编写的 OC 代码,底层都是基于它来实现的.比如: [recei ...

  9. 《Android NFC 开发实战详解 》简介+源码+样章+勘误ING

    <Android NFC 开发实战详解>简介+源码+样章+勘误ING SkySeraph Mar. 14th  2014 Email:skyseraph00@163.com 更多精彩请直接 ...

随机推荐

  1. Android系统学习小记

    序言 Android 应用的启动到一个页面显示出来,这个过程涉及到点击事件的处理,以及如何启动一个Activity,启动一个Activity之后,如何将Activity中我们的设置的ContentVi ...

  2. Redis中持久化的两种方法详解

    Redis提供了两种不同的持久化方法来将数据存储到硬盘里面.一种方法叫快照(snapshotting),它可以将存在于某一时刻的所有数据都写入硬盘里;另一种方法教只追加文件(append-only f ...

  3. Linux硬链接和软链接

    1.Linux链接概念Linux链接分两种,一种被称为硬链接(Hard Link),另一种被称为符号链接(Symbolic Link).默认情况下,ln命令产生硬链接. [硬连接]硬连接指通过索引节点 ...

  4. 面试题目——《CC150》数学与概率

    面试题7.2:三角形的三个顶点上各有一只蚂蚁.如果蚂蚁开始沿着三角形的边爬行,两只或三只蚂蚁撞到一起的概率有多大?假定每只蚂蚁会随机选一个方向,每个方向被选到的几率相等,而且三只蚂蚁的爬行速度相同. ...

  5. zabbix3.0.4 邮件告警详细配置

    sendEmail是一个轻量级,命令行的SMTP邮件客户端.如果你需要使用命令行发送邮件,那么sendEmail是非常完美的选择:使用简单并且功能强大.这个被设计用在php.bash perl和web ...

  6. Python SMTP邮件模块

    SMTP是发送邮件的协议,Python内置对SMTP的支持,可以发送纯文本邮件.HTML邮件以及带附件的邮件. Python对SMTP支持有smtplib和email两个模块,email负责构造邮件, ...

  7. linuxmint 17没有vim

    首先上软件管理器中安装vim,之后配置.vimrc文件 下面是从网上摘抄的配置文件: """""""""&qu ...

  8. UVALive 3027 Corporative Network

    ---恢复内容开始--- Corporative Network Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld ...

  9. 明晨HOSTS编辑器mcHostsEdtor与火狐HostAdmin配合使用

    在开发过程中,需要经常切换环境开发.测试.Stage和正式环境,甚为麻烦. 后来找到了HOST切换工具mcHostsEdtor工具快速切换host,但浏览器比如有HOST缓存,后来同事推荐FireFo ...

  10. PHP通用的XSS攻击过滤函数,Discuz系统中 防止XSS漏洞攻击,过滤HTML危险标签属性的PHP函数

    XSS攻击在最近很是流行,往往在某段代码里一不小心就会被人放上XSS攻击的代码,看到国外有人写上了函数,咱也偷偷懒,悄悄的贴上来... 原文如下: The goal of this function ...