Margin Auto tutorial in Flexbox CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Margin Auto Flexbox CSS</title>
<link rel="stylesheet" href="css/Margin_Auto_Flexbox_CSS.css">
</head>
<body>
<h1>Margin Auto Flexbox CSS</h1>
<div class="container">
<div class="items item1">One</div>
<div class="items item2">Two</div>
<div class="items item3">Three</div>
<div class="items item4">Four</div>
</div>
</body>
</html>
Below File is css/Margin_Auto_Flexbox_CSS.css File
body {
font-family: arial, helvetica;
}
h1 {
padding: 0 0 0 40px;
}
.container {
background: #eee;
margin: 50px;
padding: 0px;
border: 4px solid #000000;
display: flex;
}
.item1 {
background: #ff4500;
}
.item2 {
background: #9acd32;
margin-right: auto;
}
.item3 {
background: #9370d8;
margin-right: auto;
}
.item4 {
background: #ff69b4;
}
.items {
color: #ffffff;
font-size: 20px;
font-weight: bold;
padding: 0px;
height: 100px;
width: 100px;
text-align: center;
/* margin: auto; */
/* margin-left: auto; */
/* margin-top: auto;
margin-left: auto; */
}
.png)
.png)
.png)
.png)
.png)
.png)
Comments
Post a Comment