Position
demo.html
demo.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS Position Demo</title>
<style>
body {
font-family: Arial, sans-serif;
height: 1500px;
padding: 20px;
}
.container {
position: relative;
border: 2px solid black;
padding: 40px;
margin-bottom: 40px;
}
.box {
width: 120px;
height: 60px;
background: lightblue;
text-align: center;
line-height: 60px;
border: 2px solid black;
}
/* STATIC (default) */
.static {
position: static;
}
/* RELATIVE */
.relative {
position: relative;
top: 20px;
left: 20px;
background: lightgreen;
}
/* ABSOLUTE */
.absolute {
position: absolute;
top: 10px;
right: 10px;
background: orange;
}
/* FIXED */
.fixed {
position: fixed;
bottom: 10px;
right: 10px;
background: red;
color: white;
}
/* STICKY */
.sticky {
position: sticky;
top: 0;
background: purple;
color: white;
padding: 10px;
}
</style>
</head>
<body>
<h1>CSS Position Demo</h1>
<div class="sticky">Sticky Header</div>
<div class="container">
<div class="box static">Static</div>
<div class="box relative">Relative</div>
<div class="box absolute">Absolute</div>
</div>
<div class="box fixed">Fixed</div>
</body>
</html>
demo.html
demo.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS Position Demo</title>
<style>
body {
font-family: Arial, sans-serif;
height: 1500px;
padding: 20px;
}
.container {
position: relative;
border: 2px solid black;
padding: 40px;
margin-bottom: 40px;
}
.box {
width: 120px;
height: 60px;
background: lightblue;
text-align: center;
line-height: 60px;
border: 2px solid black;
}
/* STATIC (default) */
.static {
position: static;
}
/* RELATIVE */
.relative {
position: relative;
top: 20px;
left: 20px;
background: lightgreen;
}
/* ABSOLUTE */
.absolute {
position: absolute;
top: 10px;
right: 10px;
background: orange;
}
/* FIXED */
.fixed {
position: fixed;
bottom: 10px;
right: 10px;
background: red;
color: white;
}
/* STICKY */
.sticky {
position: sticky;
top: 0;
background: purple;
color: white;
padding: 10px;
}
</style>
</head>
<body>
<h1>CSS Position Demo</h1>
<div class="sticky">Sticky Header</div>
<div class="container">
<div class="box static">Static</div>
<div class="box relative">Relative</div>
<div class="box absolute">Absolute</div>
</div>
<div class="box fixed">Fixed</div>
</body>
</html>