移动端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 ...
随机推荐
- 【BZOJ2427】[HAOI2010]软件安装(动态规划,Tarjan)
[BZOJ2427][HAOI2010]软件安装(动态规划,Tarjan) 题面 BZOJ 洛谷 题解 看到这类题目就应该要意识到依赖关系显然是可以成环的. 注意到这样一个性质,依赖关系最多只有一个, ...
- 软Raid5制作
以raid5为例: 1.添加4块磁盘要求:容量.转速.接口一样的硬盘. 2.创建分区并修改ID[root@localhost ~]# fdisk /dev/sdb[root@localhost ~]# ...
- UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There Was One / POJ 3517 And Then There Was One / Aizu 1275 And Then There Was One (动态规划,思维题)
UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There W ...
- CF 468B Two Sets
题意: 给定n个正整数与a,b两个集合,求一种方案使得这n个数恰好被分在这两个集合中且集合中无多余的数且若x在a中则A-x在a中,若x在b中则B-x在b中. 题意理解了我好半天... 解法1:并查集. ...
- (next_permutation)Ignatius and the Princess II hdu102
Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ( ...
- (compareTo) How Many Fibs hdu1316 && ZOJ1962
How Many Fibs? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- python备份网站,并删除指定日期文件
#!/usr/bin/python# Filename: backup_ver1.pyimport osimport timeimport datetime# 1. The files and dir ...
- python写GUI
图形用户界面 本文利用wxpython wx包中的方法都是以大写的字幕开头 import wx def load(event): file = open(filename.GetValue()) co ...
- Python基础【day01】:python介绍发展史(一)
本节内容 Python介绍 发展史 Python 2 or 3? 一. Python介绍 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏 ...
- Hbase记录-Hbase基础概念
HBase是什么? HBase是建立在Hadoop文件系统之上的分布式面向列的数据库.它是一个开源项目,是横向扩展的. HBase是一个数据模型,类似于谷歌的大表设计,可以提供快速随机访问海量结构化数 ...