简单适配方案1px的边框为啥不用rem表示,而其他的div宽高可以,不都是一样的么

来源:3-3 通用适配应用--头部header

慕瓜0581623

2019-06-10 13:28:25

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
   <title>Title</title>
   <style>
       * {
           margin: 0;
           padding: 0
}
       .header{
           height: 2.5rem;
           background-color: red;
           border-bottom: 0.025rem solid white;
       }
   </style>
</head>
<body>
<div class="header">0.025rem solid white;</div>
<div style="height: 50px;background-color: green;font-size: 14px">和哈</div>
<script>
   adaptive();
   window.addEventListener("resize",function(){
       adaptive();
   });
   function adaptive(){
       var html = document.querySelector('html');
       var width = html.getBoundingClientRect().width;
       html.style.fontSize = width / 18.75 + 'px';
   }
</script>
</body>
</html>

写回答

1回答

bbbboom

2019-06-10

兄弟,你是想解决1px边框问题吗?后面通用适配方案中讲解了啊。

0

0 学习 · 6815 问题

查看课程