即使你没有使用它,为什么rem会打破flex布局

时间:2017-02-08 09:43:59

标签: css



<!DOCTYPE html>
<html>

<head>

  <link rel="icon" href="data:;base64,iVBORw0KGgo=">
  <meta charset='utf-8'>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    html {
      overflow: scroll;
      min-height: 100%;
      display: flex;
      font-size: 62.5%;
    }
    body {
      display: flex;
      flex: 1;
    }
    .chats {
      flex: 1;
      display: flex;
      flex-direction: column;
    }
    p {
      padding: 10px;
    }
    .box {
      background: blue;
      flex: 1;
    }
    .random {
      padding-top:1rem;
      /* try to un-commnet this rule and the observe the blue box, it will become very small */
    }
  </style>
</head>

<body>
  <div class="chats">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
      dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <div class="box">box</div>
  </div>
</body>

</html>
&#13;
&#13;
&#13;

问题:如果我取消注释规则.random。即使我没有在html

中的任何地方使用它,布局也会中断

重现:你需要在手机上查看此代码(safari / chrome)

没有规则.random的屏幕截图

enter image description here

使用规则.random

enter image description here

0 个答案:

没有答案