Reputation: 161
I want to set different margins to two divs, inside another div. The first div should appear top of the second div.
<div style="position:relative">
<div style="position: absolute;margin-top:24px">
This should be appar top of the second div.
</div>
<div style="margin-top:24px">
second div
</div>
</div
I used above mention code, but first div also getting margin 50
, not margin 24
.
How to resolve this issue?
Cannot use position:absoulte
to the second div.
Upvotes: -1
Views: 62
Reputation: 979
You can use the following code:
<div style="position:relative">
<div style="posiotion:absolute, top:24px">
This should be appar top of the second div.
</div>
<div>
second div
</div>
</div>
Upvotes: 1