I want to center 4 boxes at the center of a page, i.e., they should be vertically centered and horizontally, one box should be at extreme left, one at extreme right and the left ones should be placed horizontally between the extreme ones. I know that such a question have been asked before, but I am not getting the exact logic of the solution. Can someone please give a proper explanation for the same? Thanks a lot. Here's the HTML code-
.cards div{
height: 200px;
width: 200px;
float: left;
text-align: center;
margin-left: 100px;
}
.card_1{
background-color: green;
}
.card_2{
background-color: blue;
}
.card_3{
background-color: yellow;
}
.card_4{
background-color: red;
}
<html>
<head>
<link rel="stylesheet" href="second.css">
</head>
<body>
<div class="cards">
<div class="card_1">
</div>
<div class="card_2">
</div>
<div class="card_3">
</div>
<div class="card_4">
</div>
</div>
</body>
</html>