移动端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 ...
随机推荐
- bzoj3672/luogu2305 购票 (运用点分治思想的树上cdq分治+斜率优化dp)
我们都做过一道题(?)货币兑换,是用cdq分治来解决不单调的斜率优化 现在它放到了树上.. 总之先写下来dp方程,$f[i]=min\{f[j]+(dis[i]-dis[j])*p[i]+q[i]\} ...
- 迅雷thunder://协议解密
echo -n 'thunder://''Cg==' | sed 's?thunder://??' | base64 -d | sed 's/^AA//; s/ZZ$//' 将thunder://替换 ...
- 字节流转字符流OutputStreamWriter、InputStreamReader,关闭流的方法
转换时可以指定编码格式:GBK.UTF-8 public class Demo { public static void main(String[] args) { File f = new File ...
- C++初始化列表(good)
本文转载自http://www.cnblogs.com/graphics/archive/2010/07/04/1770900.html 感谢作者分享 何谓初始化列表 与其他函数不同,构造函数除了有名 ...
- MUI 当input聚焦之后,弹出自带的键盘之后,内容往上移动
1)有时候为了用户更好的体验,当input聚焦之后,手机自带的键盘弹出的时候,页面的内容也要跟着滚动,好让键盘不遮住input 只要把input标签放到mui-content这个类里面就可以了 < ...
- 2018acm-icpc西安邀请赛后记
第一次参加icpc的邀请赛,有一点小激动,深知大一弱队实力弱,赛前给队友的目标就是拿块铜,不打铁. 热身赛因为没有用过pc^2,codeblocks又用不习惯的原因,开始调工程调了很久,差一点拿到A题 ...
- python - how to sort
python - how to sort overview Key function (★★★★★) OPerator module functions asc and desc 升序和降序 Over ...
- 搭建Spring4+Spring MVC web工程的最佳实践
Spring是个非常非常非常优秀的java框架,主要是用它的IOC容器帮我们依赖注入和管理一些程序中的Bean组件,实现低耦合关联,最终提高系统可扩展性和可维护性,用它来辅助我们构建web工程将会感觉 ...
- System.Runtime.InteropServices.COMException:“服务器出现意外情况。 (异常来自
.Net MVC导出Excel的时候,一直报错,如题.原因是因为福昕阅读器,这样设置 execl->点击文件>选项>加载项,选择com加载项,把祈福阅读器勾掉.
- Datatables 完整的datatables案例
这里只做收集网上一些很棒的博客!!!真的是很棒!!! https://www.cnblogs.com/luckychan/articles/6160934.html