移动端遇到的bug个解决方法

内容并不是很全,以后每遇到一个问题都会总结在这里,分享给大家!

 

一、meta标签的相关知识1、移动端页面设置视口宽度等于设备宽度,并禁止缩放。
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、当网站添加到主屏幕快速启动方式,可隐藏地址栏,仅针对ios的safari1 
    <meta name="apple-mobile-web-app-capable" content="yes" /><!-- ios7.0版本以后,safari上已看不到效果 -->

6、将网站添加到主屏幕快速启动方式,仅针对ios的safari顶端状态条的样式
 <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、禁止ios和android用户选中文字
.css{-webkit-user-select:none}

2、禁止ios长按时触发系统的菜单,禁止ios&android长按时下载图片
.css{-webkit-touch-callout: none}

3、webkit去除表单元素的默认样式
.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);}

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

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

7、android 上去掉语音输入按钮

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

8、移动端定义字体,移动端没有微软雅黑字体/* 移动端定义字体的代码 */

body{font-family:Helvetica;}

 

三、其他技巧1、手机拍照和上传图片
<!-- 选择照片 -->
<input type=file accept="image/*">

<!-- 选择视频 -->
<input type=file accept="video/*">

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

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

3、打电话和发短信
<a href="tel:0755-10086">打电话给:0755-10086</a>
<a href="sms:10086">发短信给: 10086</a>


 

四、flex弹性布局

1、定义弹性盒模型兼容写法/*boxinline-box*/

display: -webkit-box;display: -moz-box;display: -ms-flexbox;display: -o-box;display: box;

2、box-orient 定义盒模型内伸缩项目的布局方向/*** vertical column 垂直* horizontal row 水平 默认值*/

-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
-ms-flex-direction: row;
-o-box-orient: horizontal;
box-orient: horizontal;

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

display:-moz-box;-moz-box-direction:reverse;

/* Safari、Opera 以及 Chrome */

display:-webkit-box;-webkit-box-direction:reverse;

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

-webkit-box-pack: center;
-moz-box-pack: center;
-ms-flex-pack: center;
-o-box-pack: center;
box-pack: center;

5、box-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;
}

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值