最大化浮动div? [英] Maximize a floating div?

查看:140
本文介绍了最大化浮动div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有两个并排的div:1 float向左,另一个float向右。现在说我固定左浮动div的大小说200px。如何强制右浮动div自己最大化或占据水平屏幕空间的其余部分(不管浏览器窗口的大小?

解决方案

这里有一个解决方案(反向,右边固定为200像素),使用position:absolute



这里有一个解决方案,左边是固定的200px



方法:您基本上修正左侧边栏,并在右边的弹性列中添加一个边距,这相当于边栏的宽度。 / p>

代码如下所示:

  .left {
width:200px;
position:absolute;
left:0;
top:0;
height:100px;
background-color:#999;
}
.right {
min-height:100px;
background-color:#666;
margin-left:200px; / *与左边的宽度相同* /
}

他们都在IE6上工作。


Say I have 2 divs side by side: 1 float left, and the other float right. Now say I fix the size of the left floating div to say 200px. How do I force the right floating div to "maximize" itself or occupy the rest of the horizontal screen space (regardless of the size of the browser window?

解决方案

Here's a solution (inverted, right is fixed 200px) for you using position:absolute.

Here's a solution where the left is fixed 200px.

The method: you basically fix the left "sidebar" and add a margin to the right flexible column which is equivalent to the sidebar's width.

The code looks like this:

.left {
    width: 200px;
    position: absolute;
    left: 0;
    top: 0;
    height: 100px;
    background-color: #999;
}
.right {
    min-height: 100px;
    background-color: #666;
    margin-left: 200px; /* Same as left's width */
}​

They both work in IE6 as is.

这篇关于最大化浮动div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆