[英]div width not stretching 100% on lower resolutions
I'm working on a website for a client, and I'm not excellent at css... still in the process of learning a lot about divs. 我正在为客户开发一个网站,但我在CSS方面并不出色...仍在学习有关div的很多知识。 I made a div that is supposed to stretch 100% of the page, and it works, unless a user is browsing from a lower resolution (1024 x 768 for example) and has to scroll horizontally, the div will then only extend to the original length of the browser window.
我制作了一个div,该div应该可以拉伸100%的页面,并且可以正常工作,除非用户从较低分辨率(例如1024 x 768)浏览并且必须水平滚动,否则div只会扩展到原始分辨率浏览器窗口的长度。
That coupled with the fact that my footer is behaving the same way, and is not sticking to the bottom of the page. 再加上我的页脚具有相同的行为,并且没有停留在页面底部的事实。
The code/website can be found at: http://cliqthis.com/temp/roadhouse/index.php 可以在以下位置找到该代码/网站: http : //cliqthis.com/temp/roadhouse/index.php
Thank you for any assistance, or an explanation of why this is happening would be helpful as I am still in the process of learning. 谢谢您的协助,或者解释为什么会这样,因为我仍在学习中。
You see the scrollbar for resolution 1024x768 because <div id='container'>
has a width of 1064 pixels set on it. 您会看到分辨率为1024x768的滚动条,因为
<div id='container'>
的宽度设置为1064像素。 The parent div will have a minimum width of 1064 due to this. 因此,父div的最小宽度为1064。
Are we talking about the black bars not extending all the way to the right? 我们是在谈论黑条没有一直延伸到右边吗?
You need to make sure not only that those divs' widths are 100%, but that all their ancestors' widths are also 100%. 您不仅需要确保这些div的宽度为100%,而且还必须确保其所有祖先的宽度也为 100%。 With normal (static) positioning, the 100% width means 100% of the element's parent's width.
在常规(静态)定位下,100%宽度表示元素父级宽度的100%。
Using the Web Developer addon in Firefox, with Outline Current Element turned on should prove very helpful in determining which elements aren't as wide as they need to be. 事实证明,在Firefox中使用Web Developer插件并启用Outline Current Element时,对确定哪些元素没有需要的宽度非常有用。 (Move your mouse around the page and it will outline the element you're over, and tell you the css selector path to it).
(将鼠标移到页面上,它将概述您结束的元素,并告诉您CSS的选择器路径)。
Also you might want to compare the structure to the original template you used. 另外,您可能想将结构与您使用的原始模板进行比较。 It seems odd to me that, for example, you have an empty div.#footer element, and then a table.foot element after it, rather than inside of it.
例如,您有一个空的div。#footer元素,然后是一个table.foot元素,而不是它的内部,这对我来说似乎很奇怪。 Perhaps you accidentally broke something there?
也许您不小心弄坏了那里的东西?
设置div的最小宽度。
div.class { /* ... */ min-width: ___px !important; /* ... */ }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.