我需要帮助,因为我已经试了很长时间来解决这个问题。我需要:
我有一个两列布局,左边的列固定宽度为220px,右边的列宽度是流体的。
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Fluid</title>
<style type="text/css" media="screen">
html, body { background: #ccc; }
.wrap { margin: 20px; padding: 20px; background: #fff; }
.main { margin-left: 220px; width: auto }
.sidebar { width: 200px; float: left; }
.main,
.sidebar { background: #eee; min-height: 100px; }
</style>
</head>
<body>
<div class="wrap">
<div class="sidebar">This is the static sidebar</div>
<div class="main">This is the main, and fluid div</div>
</div>
</body>
</html>
完全没有问题。当我在右列使用CSS语法clear: both时,所有内容都会被移到左列下面。这是正确的行为,没有任何问题。
但我真的需要在右列中使用clear:both,使其保持在右列的上下文中(完全不受左列的影响,并且不会移动到左列下面)
是否有简单的方法来保留页面设计的基本浮动概念?
更新:请查看此链接以了解我的意思,因为我的描述可能有点混淆。 链接:http://jsfiddle.net/k4L5K/1/