我想以这种方式对齐 div block :
+-----+------+ |first|second| | | | + +------+ | |third | | | | +-----+------+
But the following code allign it in other manner:
<html>
<head>
<style>
.common
{
border: 1px solid black;
float: left;
}
#first
{
background: red;
height: 100px;
width: 50px;
}
#second
{
background: green;
height: 50px;
width: 50px;
}
#third
{
background: yellow;
height: 50px;
width: 50px;
}
</style>
</head>
<body>
<div class="common" id="first">first</div>
<div class="common" id="second">second</div>
<div class="common" id="third">third</div>
</body>
</html>
我不会使用绝对定位。
还有其他方法吗?
谢谢你提前。
最佳答案
您可以将 second 和 third 包装在容器 div 中,然后 float 容器和 first。
#first {
float: left;
}
#container {
float: left;
}
...
<div id="first></div>
<div id="container">
<div id="second"></div>
<div id="third"></div>
</div>
关于css - 从另一个 DIV block 的一侧对齐 DIV block 的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4287853/