Hi dear welcome to "CodePrime" Blog . In this post we are going to learn how to use css position 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 Position Property</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="title">CSS Position Property</div>
<div class="container">
<div class="position-1"></div>
<div class="position-2"></div>
</div>
</body>
</html>
CSS
*{
font-family: sans-serif;
}
body{
min-height: 500vh;
}
.title{
font-size: 2rem;
background: linear-gradient(45deg,#f09, #111);
padding: 5px 10px;
text-align: center;
color: #fff;
margin-top: 20px;
text-transform: uppercase;
}
.container{
/* position: relative; */
/* position: absolute; */
/* position: fixed; */
padding: 10px;
border-radius: 5px;
box-shadow: 0 0 3px #ccc;
margin: 30px 30%;
width: fit-content;
}
.container .position-1 {
/* position: relative; */
/* position: absolute; */
/* position: fixed; */
width: 200px;
height: 200px;
border-radius: 5px;
background: #090;
margin: 10px;
}
.container .position-2 {
/* position: relative; */
/* position: absolute; */
/* position: fixed; */
width: 200px;
height: 200px;
border-radius: 5px;
background: #f09;
margin: 10px;
}
0 Comments