100% DIV 宽度并不是真正的 100% [英] 100% DIV width is not really 100%

查看:24
本文介绍了100% DIV 宽度并不是真正的 100%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我有一个

width: 100% 时,它并不是真正的 100%:

testtesttesttesttest

...#div {宽度:100%;背景颜色:红色;}

现在当你调整窗口大小时,会有一个水平滚动条,你向右滚动,然后背景消失了.在这种情况下,我如何保留背景?

在这里您可以看到问题的实际情况:http://beta.ovoweb.net/?i=3

现在,当您调整窗口大小并向右滚动时,您将无法再看到背景.如何解决这个问题?

解决方案

100% 值是父级宽度或视口的 100%.请参阅文档.

When I have a <div> with width: 100%, it is not really 100%:

<div id="div">testtesttesttesttest</div>

...

#div {
  width: 100%;
  background-color: red;
}

Now when you resize the window, so there is a horizontal scrollbar, and you scroll to the right, then the background is vanished. How can I remain the background in this case?

Here you can see the problem in action: http://beta.ovoweb.net/?i=3

Now when you resize the window and scroll to the right, you can't see the background anymore. How to fix this?

解决方案

The 100% value is 100% of the parent's width or the view port. See the documentation.

这篇关于100% DIV 宽度并不是真正的 100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆