Reputation: 97
I have div inside which I want to have other divs, each one 10 px under the previous one. My css code of it is
.item{
position: absolute;
left: 15px;
right: 15px;
height: 80px;
border: dashed 2px black;
margin: auto;
margin-top: 10px;
}
but it places every div in the same place(10px under top of parent div). How can I do it?
Additionaly I want to have a slider, when there is not enough place to contain all of divs.
Upvotes: 0
Views: 51
Reputation: 1182
Just set to position: relative :)
.item{
position: relative;
margin-top: 10px;
margin-left: 15px;
margin-right: 15px;
height: 80px;
border: dashed 2px black;
}
<div class="box">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
Upvotes: 1