简体   繁体   English

浮动div填充剩余空间

[英]Floated div to fill remainder space

I have a CodePen for this set up here: http://codepen.io/anon/pen/Isqou 我在这里设置了CodePen: http ://codepen.io/anon/pen/Isqou

div.linksBox {
border:1px solid #a9a9a9;
background:#fff;
-moz-box-shadow:0 5px 12px rgba(0,0,0,0.3);
-webkit-box-shadow:0 5px 12px rgba(0,0,0,0.3);
box-shadow:0 5px 12px rgba(0,0,0,0.3);
margin:0 12px 12px 0;

text-align:center;
overflow:hidden;
}

<div id="topFloats" style="margin-top:5px; overflow:hidden; border:1px solid black; margin-top: 10px;">
    <div style="width:20px; height:340px; float:left; background-color:red;"></div>
    <div id="rightFloatWrapper" class="linksBox">
        <div class="rollover linkIconLayout" id="" style='width: 134px; height: 122px; background-color:green;' href=""></div>
        <div class="rollover linkIconLayout" id="" style='width: 142px; height: 112px; background-color:blue;' href=""</div>
    </div>
</div>

An image in the red (left) floated div sets the height of the black-bordered div. 红色(左)浮动div中的图像设置黑边div的高度。 I need an inner (drop-shadowed) div (whose minimum dimensions are set by the size of it's content divs) to expand to fill the remainder of the space in the black-bordered div. 我需要一个内部(阴影阴影)的div(其最小尺寸由其内容div的大小设置)进行扩展以填充黑色边框div中的其余空间。

I was able to fill the horizontal space by taking float off the drop-shadowed div, adding an overflow, and setting the margins to accommodate the drop-shadow. 我能够通过从阴影下的div上移除浮点数,添加溢出并设置边距以适应阴影来填充水平空间。 How can I fill the remaining vertical space? 如何填充剩余的垂直空间?

Solved. 解决了。 I ended up abandoning floats and using position:absolute;right:0; bottom:0;top:0; 最终放弃了浮动,并使用position:absolute;right:0; bottom:0;top:0; position:absolute;right:0; bottom:0;top:0; on the inner (drop-shadowed) div. 在内部(阴影)div上。 The trick was to use a right:5% and set the (previously floated) red div width to the same ( width:5% ). 诀窍是使用right:5% ,并将(先前浮动的)红色div宽度设置为相同的( width:5% )。 This accomplished what I was attempting to do with the floated divs and still keeps the flexibility of a liquid layout (with the small downside that if I change the width, I need to make sure to change the right: property as well). 这完成了我尝试使用浮动div时所做的事情,并且仍然保持了液体布局的灵活性(缺点是,如果我更改宽度,还需要确保同时更改right:属性)。

Hopefully this will help someone else that tries this. 希望这会帮助其他尝试此方法的人。

Cheers! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM