是否可以在绝对定位的div中有多个浮点数而不指定绝对容器的宽度?
见图:

Ninja编辑: 你的绝对和浮动代码完美无缺,但不是我的情况.我试图简化问题,但显然还有其他问题.我一找出原因便立刻回复你.抱歉.
编辑2: 对,这是我的问题的原因.
HTML
<div id="anotherContainer">
Outercontainer
<div class="main">
<div class="left">Left</div>
<div class="right">Right</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
#anotherContainer {
position: relative;
outline: 4px solid red;
width: auto;
height: auto;
display: inline-block;
}
.main{
border: 1px solid #f00;
position: absolute;
}
.left{
float: left;
border: 1px solid #0f0;
padding: 20px;
}
.right{
float: right;
border: 1px solid #00f;
padding: 20px;
}?
Run Code Online (Sandbox Code Playgroud)
我的错误,我认为容器#anotherContainer对此没有任何影响.
css ×1