响应部门问题

时间:2018-02-22 17:23:21

标签: css

其中一个ID="div"没有响应。我试过我的Android手机,甚至在我的windows bluestack模拟器上,但它真的不动。

#div {
      background-color: #fff;
      border: 1px solid #dedede;
      border-radius: 4px;
      box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.055);
      color: #888;
      display: block;
      margin: 8px 22px 8px 22px;
      overflow: hidden;
      width: 100%; 
}

1 个答案:

答案 0 :(得分:0)

可能发生的事情是你的父元素有一个固定的宽度,迫使你的#div元素与你的父元素的宽度相同。

width:100%强制您的元素为父元素的100%宽度。因此,例如,如果您的父元素是另一个<div>,您还需要确保该元素也具有响应宽度。

这是一个基本的例子:

<!-- This will be 100% to the browser window -->
<div style="width: 100%">
  <div style="width: 100%">
    <!-- this div will be 100% of the window because the parent is 100% -->
  </div>
</div>

<!-- This will always be 1200px wide, not matter how wide the browser window is -->
<div style="width: 1200px">
  <div style="width: 100%">
    <!-- this div will be 1200px wide because the parent is 1200px -->
  </div>
</div>

相关问题