silviagreen
silviagreen

Reputation: 1729

Overlap divs without using position:absolute

is it possible to overlap two divs without using position:absolute? Is there any example? I have to remove the position:absolute to use the page-break rule.

Upvotes: 0

Views: 1164

Answers (1)

Canser Yanbakan
Canser Yanbakan

Reputation: 3870

Yes there is. Use negative margin.

For example;

<div id="box1" class="box">CONTENT HERE</div>
<div id="box2" class="box">SOME STUFF HERE</div>

<style>
.box {
    position: relative;
    width: 50%;
    float: left;
    border: 1px dashed #000;
    padding: 25px;
    box-sizing: border-box;
}

.box#box2{
    margin-left: -20px;
}
</style>

Test here:

https://jsfiddle.net/2r7623st/

Upvotes: 2

Related Questions