如何使div覆盖页面的整个宽度,而不是更改内部的内容?

时间:2017-08-24 04:49:07

标签: css

如何让div覆盖页面的整个宽度,而不是更改内部的内容?我已经尝试了

#maindiv{
margin-right:-100px;
margin-left:-100px;
}

1 个答案:

答案 0 :(得分:0)

您要找的是使用 position: fixed ,同时为0 top设置left的值},rightbottom属性:

#full {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: cyan;
}
<div id="full">Text</div>

希望这有帮助! :)

相关问题