【发布时间】:2014-04-29 14:26:38
【问题描述】:
我希望将两个 div 放在一个容器中,它们彼此相邻,它们占据容器的 100%,并且两者之间有固定数量的填充。是否可以在不知道 div 的宽度或使用百分比的情况下这样做。希望这个示例代码能让我对我想要实现的目标有所了解。
.orange {
position:absolute;
top:0;
width:45%;
background-color:orange;
}
.yellow {
width:auto;
background-color:yellow;
}
<!--sample html-->
<div style="position:relative;width:100%">
<div class="orange">Orange Div</div>
<div class="yellow">I want this div to start 10px to the right of the orange div</div>
</div>
【问题讨论】:
标签: css dynamic width positioning absolute