I want to align the child Div under my parent Div based on its class on the left, right, or center.
I have done the following:
.container{
border:1px solid;
padding:1px;
width:100%;
margin:1px;
}
.left-item{
float:left;
padding:auto;
margin:1px;
}
.center-item{
padding:auto;
margin:1px;
}
.right-item{
float:right;
padding:auto;
margin:1px;
}
<div class="container">
<button class="left-item">Left</button> <button class="center-item">Center 2</button> <button class="right-item">Right</button> <button class="left-item">Left</button> <button class="right-item">Right</button> <button class="center-item">Center 1</button> <button class="center-item">Center 3</button>
</div>
Run codeHide resultI can not align child Divs with the center to the parent Divs. Can anyone help me with this?
source
share