How can I get overlapping divs with relative positions?

前端 未结 4 1804
南笙
南笙 2020-12-28 14:06

I want a few divs to be positioned in a line next to each other, but also allow them to overlap the previous div.

What I\'m trying to get is a timeline with divs for

4条回答
  •  清酒与你
    2020-12-28 14:55

    Use Negative Margins!

    Fiddle: http://jsfiddle.net/vZv5k/


    Another Solution:

    Give the .day class a width, height, and position it relatively, keeping the inner divs absolutely positioned.

    Check out the below CSS:

    .day {position: relative; width: 500px; height: 500px;}
    

    And the HTML:

提交回复
热议问题