/*================================================================
以下为基于ip5 宽度320做的适配,标准html{font-size:10px},即1rem = 10px
=================================================================*/
@mixin queryWidth($min, $max) {
@if $min == -1 {
@media screen and (max-width: $max+px) {
html {
font-size: ( ($max+1) / 320 ) * 10px;
}
}
} @else if $max == -1 {
@media screen and (min-width: $min+px) {
html {
font-size: ( $min / 320 ) * 10px;
}
}
} @else {
@media screen and (min-width: $min+px) and (max-width: $max+px) {
html {
font-size: ( $min / 320 ) * 10px;
}
}
}
} @media only screen and (orientation: landscape) {
html {
font-size: 10px;
}
} @include queryWidth(-1, 319); // for iphone 4
@include queryWidth(320, 359); // for iphone 5
@include queryWidth(360, 374);
@include queryWidth(375, 383); // for iphone 6
@include queryWidth(384, 399);
@include queryWidth(400, 413);
@include queryWidth(414, -1); // for iphone 6 plus

以上为基于320的设计稿,若要基于375,只需将mixin中320改为375即可。若要100px=1rem,只需将mixin中10改成100即可。当然,这只能实现大部分常规机型的适配,有些特殊机型还是需要自己再加上对应的适配。

  接下来罗列一下我用到过的适配,希望得到各位帮助逐步完善。

@media screen and (min-width: 320px) {} //for iphone 5
@media screen and (min-width: 375px) {} //for iphone 6
@media screen and (min-width: 414px) {} //for iphone 6 plus
@media screen and (min-aspect-ratio: 69/100) {} //for huawei荣耀6
@media screen and (min-aspect-ratio: 7/10) {} //for mx3
@media screen and (max-height: 480px) {} //for iphone 4
@media screen and (max-height: 420px) {} //for iphone 4 微信
@media only screen and (orientation: landscape) {} // for 横屏

原文地址:http://www.cnblogs.com/McChen/p/5017120.html

@media (min-width:320px) and (min-height:480px) {
.code{top: 42vh!important;}
} @media (min-width:320px) and (min-height:568px) {
.code{top: 32vh!important;}
}

最新文章

  1. centos7.0 安装字体库
  2. Remove Duplicates from Sorted Array II [LeetCode]
  3. Leetcode Combination Sum II
  4. 转载部长一篇大作:常用排序算法之JavaScript实现
  5. jQuery上传插件,文件上传测试用例
  6. Get Many Persimmon Trees_枚举&&二维树状数组
  7. Linux常用命令记录
  8. supervisor tornado 多进程多端口配置
  9. 矩阵分解(rank decomposition)文章代码汇总
  10. WPF中常用控件的属性
  11. BootStrap基礎知識
  12. NOI2017游记
  13. iOS使用自签名证书实现HTTPS请求
  14. BZOJ_4269_再见Xor_线性基
  15. 探索PowerShell 【十三】WMI对象
  16. php操作Memcache的一个类库
  17. mpvue——引入echarts打包vendor过大
  18. echarts研究
  19. 在IE浏览器中url传参长度问题
  20. Python标准数据类型的二次加工

热门文章

  1. epub格式电子书剖析之三:NCX文件构成
  2. POJ 2449
  3. win7 64位 VS2010调试提示“ORA-12154: TNS: 无法解析指定的连接标识符”的解决方法
  4. 【转】由DFT推导出DCT
  5. Linux下安装启动nginx的过程
  6. java常见机试题目(1)
  7. oracle 实例名和服务名以及数据库名区别
  8. HDOJ-ACM1012(JAVA)
  9. Add And Reset a Federation Server to a Federation Server Farm adfs ad
  10. ASP.Net IE10 _doPostBack 未定义错误【转】