[英]CSS 100% Height Issue
I have a small site I'm working where basically everything is fixed except for the content area. 我有一个小网站,我正在工作,基本上一切都是固定的,除了内容区域。 I want that content area to expand all the way to the bottom of the browser window.
我希望该内容区域一直扩展到浏览器窗口的底部。 When the site is first loaded at a screen resolution of 1024x768 it appears that it works but if you scroll down the copy continues but the colored background does not.
当网站首次以1024x768的屏幕分辨率加载时,它似乎可以正常工作,但如果向下滚动,副本会继续,但彩色背景不会。 I have searched for a solution but I've had no luck so far.
我已经找到了解决方案但到目前为止我没有运气。
Here is a link to the site: www.atriaseniorliving.com/cah/our_process.html 以下是该网站的链接: www.atriaseniorliving.com/cah/our_process.html
Edit: 编辑:
Here is the css I am using: 这是我正在使用的CSS:
#copyContainer {
width: 1000px;
height: 100%;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: 0 auto;
position: relative;
font-family: 'Droid Serif';
font-size: 16px;
line-height: 24px;
} }
#mainCopy {
display: block;
width: 390px;
height: auto !important;
margin: 127px 0 0 0;
padding: 30px;
position:absolute;
bottom:0;
top:0;
left:505px;
right:0;
z-index:99;
-webkit-box-shadow: 0px 0px 10px 0px rgba(51, 51, 51, .6);
affects the size of the padding the element. 影响元素填充的大小。
your style probably this 你的风格可能就是这样
display: inherit;
width: 390px;
height: auto;
margin: 127px 0 0 0;
padding: 30px 0px 0px 0px;
position: absolute;
top: 0;
left: 505px;
z-index: 99;
-webkit-box-shadow: 0px 0px 10px 0px rgba(51, 51, 51, .6);
box-shadow: 0px 0px 10px 0px rgba(51, 51, 51, .6);
I think you are using height:100%
incorrectly... height:100%
is referring to the height of your browser window. 我认为你正在使用
height:100%
错误... height:100%
指的是浏览器窗口的高度。 And what you think happen when an inner element has bigger height that his parent? 当一个内部元素的高度超过他的父母时,你认为会发生什么? That's your case: #mainCopy has bigger height than browser window and therefore bigger height than #copyContainer .
这是你的情况: #mainCopy比浏览器窗口更高,因此比#copyContainer更高 。 You just need to update few styles:
您只需更新几种样式:
#copyContainer {
width: 1000px;
margin: 0 auto;
font-family: 'Droid Serif';
font-size: 16px;
line-height: 24px;
height: 100%;
}
#mainCopy{
display: block;
width: 390px;
margin: 127px 0 0 0;
padding: 30px;
float: right; //No need position:absolute
bottom: 0;
top: 0;
left: 505px;
right: 0;
z-index: 99;
-webkit-box-shadow: 0px 0px 10px 0px rgba(51, 51, 51, .6);
box-shadow: 0px 0px 10px 0px rgba(51, 51, 51, .6);
}
#middleContainer {
width: 100%;
background: #D9D9D9;
position: absolute;
top: 128px;
z-index: -1; //Because the image was over the text
}
Another things you can do to improve your code: 您可以采取的其他改进代码的方法:
position:absolute
and position:fixed
without need position:absolute
position:fixed
不需要 with:1000px
use with:960px
with:1000px
使用with:960px
margin-top:xxx
instead top:xxx
on absolute positioned divs margin-top:xxx
而不是top:xxx
在绝对定位的div上 Just remove 'bottom: 0' from #mainCopy. 只需从#mainCopy中删除'bottom:0'即可。 Your element is positioned absolutely so it will only go to the bottom of its reference container which is #copyContainer.
您的元素绝对定位,因此它只会到达其引用容器的底部,即#copyContainer。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.