【发布时间】:2013-08-28 04:08:12
【问题描述】:
我的这个页面 (http://www.alsite.com.br/angelogarcia/angelogarcia.html) 有一个粘滞页脚 (http://www.cssstickyfooter.com/)。
所以我需要 div #main 是 100% 的高度减去页脚的大小(70 像素),而我的 div .conteudo 的大小与 div #main 的大小相同,高度也是 100%。我设置了颜色以便于查看发生的情况
我清楚了吗?
JSFiddle 链接:http://jsfiddle.net/EugRP/
结构是:
<body>
<div id="wrap">
<div class="main">
<div class="sidebar"></div>
<div class="conteudo"></div>
</div>
</div>
<div id="footer"></div>
</body>
我的 CSS:
html, body {
height: 100%;
}
#wrap {
min-height: 100%;
}
#main {
width:100%;
min-width: 960px;
margin: 0 auto;
background: #FFCC00;
padding-bottom: 70px; /* must be same height as the footer */
}
#footer {
position: relative;
margin-top: -70px; /* negative value of footer height */
height: 70px;
clear:both;
}
.conteudo{
padding:0 15px;
width:60%;
margin-left: 30px;
background: #000000;
background:rgba(255,0,0,0.8);
text-align: justify;
font-size: 16px;
letter-spacing: 0.8px;
}
【问题讨论】:
-
如果您可以在 jsfiddle 上创建一个简化的测试用例,那么帮助您编写代码会更容易。
-
这里是链接:jsfiddle.net/EugRP
-
根据您的浏览器支持需求,这听起来像是 calc 的工作。 caniuse.com/#search=calc 类似:
calc(100% - 70px)可能满足您的需求 -
编辑:类似这样的东西:jsbin.com/OQurEFU/2/edit?html,css,output 这就是你要找的东西吗?
-
是的,类似的东西......你的想法!..