Posições dos elementos usando CSS em HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Position CSS</title>
<style>
div{
font-size: 60px;
padding: 30px;
border: solid 5px #222;
color: red;
}
/* classes específicas */
.static{
top: 100px;
left: 100px;
background-color: steelblue;
}
.fixed{
position: fixed;
bottom: 30px;
right: 0px;
}
.relative1{
position: relative;
left: 50px;
top: 5px;/*5 pixel acima do elmento acima*/
background-color: seagreen;
}
.absolute1{
position: absolute;
left: 350px;
top: 120px;
background-color: violet;
}
.relative2{
position: relative;
left: 250;
top: 2000px;
width: 200px;
height: 200px;
background-color: salmon;
}
.absolute2{
position: absolute;
left: 10px;
top: 10px;
width: 20px;
height: 20px;
background-color: greenyellow;
}
.sticky{
position: -webkit-sticky;/*safari*/
position: sticky;
background-color: #777;
top: 10px;
}
</style>
</head>
<body>
<!-- Classes -->
<div class="static">Static (Padrão)</div>
<div class="fixed">Fixed</div>
<div class="relativel">Relative</div>
<div class="absolute1">Absolute</div>
<div class="relative2">
<div class="absolute2"></div>
</div>
<div class="sticky">Sticky</div>
<p style="padding-bottom: 2000px;">Opa</p>
</body>
</html>