Hi dear welcome to Ascode Blog . In this post we are going to learn How to use css margin property. First Creat A index.html file Copy This HTML CODE and pest it one your code editor. 2ndly creat style.css file Then Copy The CSS CODE and pest it then open the index.html file with your browser.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>css margin</title>
</head>
<body>
<div class="css-margin">
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Similique ratione ad quos ipsum optio aliquid ipsa perferendis odio commodi porro distinctio, asperiores illum autem non iste voluptatem ullam natus hic.
</div>
</body>
</html>
CSS
*{
margin: 0;
box-sizing: border-box;
padding: 0;
font-family:sans-serif ;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.css-margin {
padding: 10px 20px;
width: 350px;
background: linear-gradient(45deg, #0000ff75, #ff009977) ;
border-radius: 5px;
font-size: 1.2rem;
/* uncomment all margin property */
/* margin-top: 20%;
margin-left: 20%;
margin-right: 20%;
margin-bottom: 20%; */
/* margin: 20% auto; */
}
0 Comments