Reputation: 45
How to move
<div class="rate1"></div>
<div class="info"></div>
<div class="rate2"></div>
to center of div class="bottom"
?
.bottom {
float: left;
width: 100%;
border: 1px solid #ccc;
}
.rate1 {
width: 70px;
height: 70px;
border-radius: 70px;
border: 5px solid #f0f0f0;
float: left;
box-shadow: 1px 1px 1px 0px #e9e9e9;
background: url(http://web.arjentienkamp.com/codepen/tinder/delete.png);
margin-left: 4px;
background-size: 25px;
background-position: center;
background-repeat: no-repeat;
}
.info {
width: 40px;
height: 40px;
float: left;
}
.rate2 {
width: 70px;
height: 70px;
border-radius: 70px;
border: 5px solid #f0f0f0;
float: left;
box-shadow: 1px 1px 1px 0px #e9e9e9;
background: url(http://web.arjentienkamp.com/codepen/tinder/heart.png);
margin-left: 4px;
background-size: 25px;
background-position: center;
background-repeat: no-repeat;
}
<div class="bottom">
<div class="rate1"></div>
<div class="info"></div>
<div class="rate2"></div>
</div>
Upvotes: 0
Views: 84
Reputation: 447
You can do this easily with flexbox :
.bottom {
display : flex;
justify-content : center;
}
You should also consider to remove the float : left;
in the inner divs.
You can also check the css-tricks's centering guide for other use case.
Upvotes: 0
Reputation: 2606
Use flexbox
.bottom{
width: 100%;
border: 1px solid #ccc;
display: flex;
justify-content: center;
align-items: center;
}
.rate1{
width: 70px;
height: 70px;
border-radius: 70px;
border: 5px solid #f0f0f0;
box-shadow: 1px 1px 1px 0px #e9e9e9;
background: url(http://web.arjentienkamp.com/codepen/tinder/delete.png);
margin-left: 4px;
background-size: 25px;
background-position: center;
background-repeat: no-repeat;
}
.info{
width: 40px;
height: 40px;
}
.rate2{
width: 70px;
height: 70px;
border-radius: 70px;
border: 5px solid #f0f0f0;
box-shadow: 1px 1px 1px 0px #e9e9e9;
background: url(http://web.arjentienkamp.com/codepen/tinder/heart.png);
margin-left: 4px;
background-size: 25px;
background-position: center;
background-repeat: no-repeat;
}
<div class="bottom">
<div class="rate1"></div>
<div class="info"></div>
<div class="rate2"></div>
</div>
Upvotes: 4