0

我想对左 div 为 100% 且右保持固定的 div 产生影响

<!DOCTYPE html>
<html>
<style>
.left {
width: 100%;
float: left;
border: #ccc solid 1px;
}
.right {
width: 50px;
float:left;
border: #987 solid 1px;
}
.main {
border: #666 solid 1px;
margin: 0px auto;
}
.clear {
clear:both;
}

</style>
<body>
<div class="main">
<div class="left">
</div>
<div class="right">
</div>
<div class="clear"></div>
</div>
</body>
</html>

我知道我可以使用 table 来轻松实现这一点,但是如何使用 div 实现这一点

4

1 回答 1

0

你的意思是这个?: http: //jsfiddle.net/JPPaf/

如果您要使用边框,请在其中嵌套另一个 div 并将边框应用于该内部 div,因为它会为您节省很多问题。

<!DOCTYPE html>
<html>
<style>
.left {
margin-right:50px;
background:red;
}
.right {
width:50px;
float:right;
background:green;
}
.main {
border: #666 solid 1px;
margin: 0px auto;
}
.clear {
clear:both;
}

</style>
<body>
<div class="main">
<div class="right">
right
</div>
<div class="left">
left
</div>
<div class="clear"></div>
</div>
</body>
</html>
于 2012-05-23T14:09:09.173 回答