用户工具

站点工具


frontend:mobile

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
后一修订版
前一修订版
frontend:mobile [2016/10/17 10:54] – Add babel section memoryfrontend:mobile [2023/12/03 10:24] (当前版本) – 外部编辑 127.0.0.1
行 13: 行 13:
 ==== 兼容性 ==== ==== 兼容性 ====
  
-浏览器:Android4.0-Android4.3+**影响范围**:Android4.0 - Android4.3
  
 [[http://caniuse.com/#search=flexbox|flexbox浏览器兼容性]] [[http://caniuse.com/#search=flexbox|flexbox浏览器兼容性]]
行 22: 行 22:
  
  
-浏览器:Android4.0-Android4.3+**影响范围**:Android4.0 - Android4.3
  
 display:flex元素下的子元素都要为块级元素,否则''display: flex''不会生效,将会表现为行内元素的特性 display:flex元素下的子元素都要为块级元素,否则''display: flex''不会生效,将会表现为行内元素的特性
行 46: 行 46:
  
 ===== Babel ===== ===== Babel =====
 +
 +**影响范围**:Android4.0 - Android 4.2(or 4.3?)
  
 目前移动端代码都用''ECMAScript 2015''编写,再使用[[http://babeljs.io/|Babel]]编译为''es5'',然而常用的[[https://babeljs.io/docs/plugins/preset-es2015/|es2015 preset]]在创建模块时默认添加了''%%__%%esModule''属性 目前移动端代码都用''ECMAScript 2015''编写,再使用[[http://babeljs.io/|Babel]]编译为''es5'',然而常用的[[https://babeljs.io/docs/plugins/preset-es2015/|es2015 preset]]在创建模块时默认添加了''%%__%%esModule''属性
行 65: 行 67:
 Loose模式的意思即为对''es2015''语法实现不严格,例如仅仅将块级作用域的''let'', ''const''转换为''var'' Loose模式的意思即为对''es2015''语法实现不严格,例如仅仅将块级作用域的''let'', ''const''转换为''var''
 </WRAP> </WRAP>
 +
 +===== Font Boosting =====
 +
 +重现条件:使用[[https://github.com/imweb/mobile/issues/3|rem]]方案
 +
 +**影响范围**:理论上所有webkit内核的移动浏览器
 +
 +表现:在Chrome上看到的字体比手机上看到的要大(注意,不是Chrome浏览器默认配置最小12px字体的问题)
 +
 +原理:[[https://github.com/amfe/article/issues/10|Font Boosting]]
 +
 +解决方法:在字体容器上设置''max-height: 100%''
 +
 +===== Input Appearance =====
 +
 +**影响范围:** safari (当前版本为iOS 10)
 +
 +在 ''safari'' 上想要覆盖 ''input'' 组件的样式,记得加上 ''-webkit-appearance: none;'' ,否则会有safari的默认样式样式导致实际效果和设计图出入较大。
 +
 +<code css>
 +input {
 +  -webkit-appearance: none;
 +  appearance: none;
 +}
 +</code>
 +
 +想要隐藏掉 ''textarea'' 右下角的角标,可用 ''resize'' 禁用掉调整大小的功能:
 +
 +<code css>
 +textarea.textarea {
 +  resize: none;
 +}
 +</code>
 +
 +===== Safari border-radius =====
 +
 +**影响范围:** safari (当前版本为iOS 10)
 +
 +如想设单边 ''border-radius'',在 ''safari'' 上可能会出现四个角都有 ''border-radius'' 的情况,所以最好声明另外一边的 ''border-radius'' 为0:
 +
 +<code css>
 +.right {
 +  border-top-right-radius: 4px;
 +  border-bottom-right-radius: 4px;
 +  border-top-left-radius: 0;    /* required */
 +  border-bottom-left-radius: 0;    /* required */
 +}
 +
 +.left {
 +  border-top-right-radius: 4px;
 +  border-bottom-right-radius: 4px;
 +  border-top-left-radius: 0;    /* required */
 +  border-bottom-left-radius: 0;    /* required */
 +}
 +</code>
 +
 +===== :empty selector =====
 +
 +**影响范围:** Android 4.0-4.2
 +
 +用 ''p:empty'' 选择器来隐藏掉部分空元素时把有内容的元素都隐藏了
 +
 +示例代码:
 +
 +<code html>
 +<div class="content">
 +  <p>First line<br />
 +second line<br />
 +third line</p>
 +</div>
 +</code>
 +
 +===== Debug on UC Browser =====
 +
 +Install UC developer version: http://plus.uc.cn/document/webapp/doc5.html
 +
 +First, enable Android adb debug mode. Then open ''chrome:\/\/inspect'' and allow permission on mobile, finally inspect the browser.
 +
 +===== iPhone X 适配 =====
 +
 +在 iPhone X 系列全面屏手机会出现下图底部操作栏覆盖掉 Tabbar 的情况
 +
 +{{ :frontend:iphone-x-failed.png?400 }}
 +
 +适配步骤为:
 +
 +1. 在 ''viewport'' 添加 ''viewport-fit=cover''
 +
 +2. 给 Tabbar 添加 ''padding-bottom''
 +
 +<code css>
 +.tabbar {
 +  padding-bottom: constant(safe-area-inset-bottom);
 +  padding-bottom: env(safe-area-inset-bottom);
 +}
 +</code>
 +
 +3. 检查所有页面的元素,通过 ''@supports'' 特性检测给所有 fixed bottom 布局的元素添加额外的 ''padding-bottom'' / ''margin-bottom''
 +
 +<code css>
 +@supports (bottom: constant(safe-area-inset-bottom)) or (bottom: env(safe-area-inset-bottom)) {
 +  div {
 +    margin-bottom: constant(safe-area-inset-bottom);
 +    margin-bottom: env(safe-area-inset-bottom);
 +  }
 +}
 +</code>
 +
 +===== 微信点击漂移 =====
 +
 +**影响范围**:**iOS 微信端**
 +
 +复现条件:点击 input 输入东西后,弹出弹窗确认(fixed 布局),弹窗的按钮不好点或者出现点击漂移。
 +
 +讨论链接:[[http://html51.com/info-59028-1/|微信打开网页键盘弹起后页面上滑,导致弹框里的按钮响应区域错位]]
 +
 +**解决方案:**
 +
 +这是因为微信弹出输入法时顶开了整个页面,可以在最后一个 input blur 的时候强制页面滚动到页面顶部或者底部。
 +
 +<code javascript>
 +input.addEventListener('blur', function () {
 +  window.scrollTo(0, 0);
 +});
 +</code>
 +
 +===== Reference =====
 +
 +  * [[https://www.zhihu.com/question/34556725|在做 iOS 和 Android 的 HTML5 开发时,你都掉到过哪些坑里?]]
  
frontend/mobile.1476672846.txt.gz · 最后更改: 2023/12/03 10:24 (外部编辑)