移动端rem单位适配使用
1.适配方法
//缩放比例
!function(e,t){function i(){o=1,e.devicePixelRatioValue=o,s=1/o;
var t=a.createElement("meta");
if(t.setAttribute("name","viewport"),t.setAttribute("content","initial-scale="+s+", maximum-scale="+s+", minimum-scale="+s+", user-scalable=no"),d.firstElementChild)d.firstElementChild.appendChild(t);
else{var i=a.createElement("div");
i.appendChild(t),a.write(i.innerHTML)}}function n(){var e=Math.min(d.getBoundingClientRect().width,750);r=100*e/t.desinWidth,d.style.fontSize=r+"px"}var a=e.document,d=a.documentElement,o=(e.devicePixelRatio,1),s=1;i();var l,r=100;
t.desinWidth=640,t.baseFont=18,t.init=function(){e.addEventListener("resize",function(){clearTimeout(l),l=setTimeout(n,300)},!1),e.addEventListener("pageshow",function(e){e.persisted&&(clearTimeout(l),l=setTimeout(n,300))},!1),"complete"===a.readyState?a.body.style.fontSize=t.baseFont*o+"px":a.addEventListener("DOMContentLoaded",function(){a.body.style.fontSize=t.baseFont*o+"px"},!1),n(),d.setAttribute("data-dpr",o)}}(window,window.adaptive||(window.adaptive={}));
window['adaptive'].desinWidth = 750;
window['adaptive'].baseFont = 18;
window['adaptive'].init();
2.rem中border中的1px样式
使用sass的写法
@mixin border-1px($cl,$position){
position: relative;
border:none;
&:before {
content: '';
position: absolute;
left: 0;
top: 0;
width: 200%;
height: 200%;
#{$position}: 1px solid $cl;
transform-origin: 0 0;
transform: scale(0.5, 0.5);
box-sizing: border-box;
pointer-events: none;
}
}
css写法
/*border*/
.border-bottom-1px{
position: relative;
border:none;
}
.border-bottom-1px:before{
content: '';
position: absolute;
left: 0;
top: 0;
width: 200%;
height: 200%;
border-bottom: 1px solid #e9edf5;
transform-origin: 0 0;
transform: scale(0.5, 0.5);
box-sizing: border-box;
pointer-events: none
}
.border-top-1px{
position: relative;
border:none;
}
.border-top-1px:before{
content: '';
position: absolute;
left: 0;
top: 0;
width: 200%;
height: 200%;
border-top: 1px solid #e9edf5;
transform-origin: 0 0;
transform: scale(0.5, 0.5);
box-sizing: border-box;
pointer-events: none
}
.border-left-1px{
position: relative;
border:none;
}
.border-left-1px:before{
content: '';
position: absolute;
left: 0;
top: 0;
width: 200%;
height: 200%;
border-left: 1px solid #e9edf5;
transform-origin: 0 0;
transform: scale(0.5, 0.5);
box-sizing: border-box;
pointer-events: none
}
3.各别情况需要计算rem时使用window.innerWidth/750*105进行适配计算!!!!
移动端rem单位适配使用的更多相关文章
- 移动端rem单位用法[转]
标签: 1.rem(font size of the root element)是指相对于根元素的字体大小的单位,em(font size of the element)是指相对于父元素的字体大小的单 ...
- 移动端rem单位用法
1.rem(font size of the root element)是指相对于根元素的字体大小的单位,em(font size of the element)是指相对于父元素的字体大小的单位.它们 ...
- web移动端rem的适配
** 需求: 随着移动端设备的变化,内容也跟着变化.**先来说说rem单位,以rem为单位,其大小是根据根元素(html标签)的字体大小来判断的, 如 html的font-size:100p ...
- 移动端rem单位和px单位换算
rem单位是根据html元素的单位在页面根据不同的手机屏幕分辨率动态整体的按比例缩小或放大字体. 假如html{font-size: 14px;},那么1rem=14px; 一个div宽度48px,那 ...
- 移动端 rem单位做适配的 媒体查询节点
@media screen and (min-width:300px){html,body,input{font-size:15px}}@media screen and (min-width:320 ...
- 移动端rem字体适配JS
// 『REM』手机屏幕适配,兼容更改过默认字体大小的安卓用户 function adapt(designWidth, rem2px) { // designWidth:'设计图宽度' 1rem==r ...
- 更新 手淘 flexible 布局 rem 单位适配问题
详见链接 https://github.com/amfe/lib-flexible
- 移动端rem移动适配
https://www.cnblogs.com/jingwhale/p/5741567.html
- 关于移动端rem适配
var num = 1 / window.devicePixelRatio; var fontSize = document.documentElement.clientWidth / 10; doc ...
随机推荐
- oracle存储过程递归调用
oracle存储过程递归调用,如果where子句使用的是传入的参数, 在以后的递归调用中参数就是第一次调用的参数值,解决办法是定义变量,使用自定义的变量问题可以解决.
- volatile的实现原理与应用
Java代码在编译后会变成Java字节码,字节码被类加载器加载到JVM里,JVM执行字节码,最终需要转化为汇编指令在CPU上执行,Java中所使用的并发机制依赖于JVM的实现和CPU的指令. vola ...
- UVALive - 6436(DFS)
题目链接:https://vjudge.net/contest/241341#problem/C 题目大意:给你从1到n总共n个数字,同时给你n-1个连接,同时保证任意两个点之间都可以连接.现在假设任 ...
- Python使用TCPServer编写(多线程)Socket服务
SocketServer包对socket包进行了包装(封装),使得创建socket服务非常简单. TCPServer+BaseRequestHandler 使用TCPServer和BaseReques ...
- asp.net上传图片文件自动修改图片大小代码
#region 图片缩放 /// <summary> /// 图片缩放 /// </summary> /// <param name="savePath&quo ...
- HSRP vs VRRP
HSRP:(Hot Standby Router Protocol)-热备份路由协议 是cisco平台一种特有的技术,是cisco的私有协议. VRRP:(Virtual Router Redunda ...
- php 配置文件不加载的一次配置
最近在一台服务器上安装配置了5.6和7.1两个版本的php,之前是5.6的.使用都正常,7.1是后期安装的. 问题: 在7.1的程序目录中命名的配置文件为:php7-9026.ini,同时安装并在配置 ...
- Tomcat 或JBOSS java.lang.ArrayIndexOutOfBoundsException: 8192 解决方案【转】
错误信息: 2017-1-17 10:09:39 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() ...
- 详细解读Jquery各Ajax函数:$.get(),$.post(),$.ajax(),$.getJSON()【转】【补】
一,$.get(url,[data],[callback]) 说明:url为请求地址,data为请求数据的列表(是可选的,也可以将要传的参数写在url里面),callback为请求成功后的回调函数,该 ...
- 转--python 面试题
# 每一题都值得好好琢磨钻透 [原文地址](http://www.cnblogs.com/Allen-rg/p/7693394.html)1.Python是如何进行内存管理的? 答:从三个方面来说,一 ...