猿问

最近遇到问题,在扣去顶部的100px后,如何让他们撑满剩余高度?

不用javascript自然最好,如果js更方便的话也请一并告之吧
有实例有代码,请看:

HTML

<div class="header">header</div>
<div class="col1">col1</div>
<div class="col2">col2</div>
<div class="col3">col3</div>

CSS

.header {    width: 100%;    background: #567;    height: 100px;
}.col1, .col2, .col3 {    float: left;    width: 80px;    background: #DDD;    height: 100%;    margin-right: 10px;
}

如果有footer的情况下 

假如footer也要占位100px,一直位于下方,那中间这三列又该怎么弄呢?


慕码人8056858
浏览 214回答 2
2回答

动漫人物

padding-bottom大数值margin-bottom负大数值.col1, .col2, .col3 {&nbsp; &nbsp; float: left;&nbsp; &nbsp; width: 80px;&nbsp; &nbsp; background: #DDD;&nbsp; &nbsp; height: 100%;&nbsp; &nbsp; margin-right: 10px;&nbsp; &nbsp; padding-bottom:5000px;&nbsp; &nbsp; margin-bottom:-5000px;}

杨__羊羊

试试这个, 不知满足楼主要求否?<!DOCTYPE&nbsp;html&nbsp;PUBLIC&nbsp;"-//W3C//DTD&nbsp;XHTML&nbsp;1.0&nbsp;Transitional//EN"&nbsp;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html&nbsp;xmlns="http://www.w3.org/1999/xhtml"><head> &nbsp;&nbsp;&nbsp;&nbsp;<meta&nbsp;http-equiv="Content-Type"&nbsp;content="text/html;charset=UTF-8"/> &nbsp;&nbsp;&nbsp;&nbsp;<title>test</title> &nbsp;&nbsp;&nbsp;&nbsp;<style&nbsp;type="text/css"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.header&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width:&nbsp;100%;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;background:&nbsp;#567;&nbsp;&nbsp;&nbsp;&nbsp;&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bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.foot{height:100px;&nbsp;background-color:#ccc;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.middle{overflow:hidden;&nbsp;zoom:1;}&nbsp;&nbsp;&nbsp;&nbsp;</style></head><body><div&nbsp;class="header">header</div><div&nbsp;class="middle"> &nbsp;&nbsp;&nbsp;&nbsp;<div&nbsp;class="col1">111colsdfffffffffffffffffffffffffffffcolsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1fffffff1222</div> &nbsp;&nbsp;&nbsp;&nbsp;<div&nbsp;class="col2">col2</div> &nbsp;&nbsp;&nbsp;&nbsp;<div&nbsp;class="col3">333colsdfffffffffffffffffffffffffffffcolsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1fffffff1colsdfffffffffffffffffffffffffffffcolsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1colsdffffffffffffffffffffffffffffffffffff1fffffff1444</div></div><div&nbsp;class="foot">foot</div></body></html>
随时随地看视频慕课网APP
我要回答