gpt4 book ai didi

html - css - min-height :100% for child container, 不想工作?

转载 作者:行者123 更新时间:2023-11-28 18:33:16 24 4
gpt4 key购买 nike

我现在正在处理 Joomla 2.5 模板 @ http://development.aycdesign.net/skin ,并且已经坚持了好几天,谷歌在这个问题上一直没有 friend 。我想要完成的是拥有一个可变大小的页眉、可变大小的页脚,并且始终让内容容器至少为浏览器窗口大小的 100%。我已经尝试了几乎所有在阳光下的事情,但遇到了两个问题。

  1. 我的内容所在的容器不会扩展到其容器高度的 100%。
  2. 在必须滚动的页面上,部分内容被裁剪到页脚中。

如有任何建议,我将不胜感激,以便我可以解决此问题并继续前进!

<html>
<body>

<div id="wrapper">
<div id="top">
header
</div>
<div id="mnav">
main menu
</div>
<div id="pagewidth">
<div id="maincol">
content
</div>
</div>
<div id="footer">
footer
</div>
</div>

</body>
</html>

....和CSS:

html,body {
height:100%;
background: rgb(138, 126, 102);
color: #A5A56F;
font-family: arial, sans-serif;
font-size: .9em;
line-height: 1.25;
}

/* ******************************************************************** */
/* Wireframe Elements */
/* ******************************************************************** */
#wrapper {
position: relative;
height:auto !important;
height:100%;
min-height:100%;
}

#top {
background: rgb(0, 0, 0);
width: 100%;
}

#top .custom {
width: 80%;
margin: 0 auto 0 auto;
color: #fff;
text-align: right;
padding: .5em 0 .5em;
}

#pagewidth {
width: 80%;
min-height: 100%;
background: rgba(54, 54, 54, 0.5);
text-align: left;
margin: 0 auto;
padding-bottom: 3em;
}


#maincol {

}

#footer {
background: rgb(0, 0, 0);
width: 100%;
height: 5%;
position: absolute;
bottom: 0;
}

#footer .custom {
width: 80%;
margin: 0 auto;
color: #fff;
text-align: right;
padding: .5em 0 .5em 0;
}

最佳答案

尝试将以下 CSS 添加到 #pagewidth :

position: absolute;
top: 20px;
bottom: 5%; /* To keep the content from stretching past the footer */
left: 50%;
margin-left: -40%;

http://jsfiddle.net/H8sg8/

当你有一个 position 设置为 absolutefixed 的元素时,你可以同时使用 topbottom 将其分别拉伸(stretch)到距容器顶部和底部的距离。 leftright 也可以使用同样的方法。

Example here

关于html - css - min-height :100% for child container, 不想工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13648487/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com