【发布时间】:2012-11-23 16:55:26
【问题描述】:
我希望几个 div 并排放置在一行中,但也允许它们与前一个 div 重叠。
我想要得到的是一个带有特定长度事件的 div 的时间线。这些事件可以相互重叠。
我的想法是给每个 div 相同的顶部位置,增加 z-index 和增加左侧位置(根据事件的时间)。稍后我会通过鼠标悬停事件弹出单个 div 以可视化重叠。
我要做的是让每个 div 都放在下一个 div 之下。通过摆弄 top 属性,我可以让它们水平对齐,但我看不到模式。
<div class="day">
<div style="top: 35px; left: 200px; background-color: red; height: 50px; width:24px; z-index: 1; position: relative;"> </div>
<div style="top: 35px; left: 220px; background-color: green; height: 50px; width:24px; z-index: 2; position: relative;"> </div>
<div style="top: 35px; left: 225px; background-color: blue; height: 50px; width:48px; z-index: 3; position: relative;"> </div>
</div>
如果我使用绝对位置,元素会飞出周围的 div 并绝对定位在页面中的某个位置。
【问题讨论】:
标签: css html layer css-position