Pesquisar neste blog

30/08/2020

Propriedades CSS

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-size60px;
            padding30px;
            bordersolid 5px #222;
            colorred;
        }
        /* classes específicas */
        .static{
            top100px;
            left100px;
            background-colorsteelblue;
        }
        .fixed{
            positionfixed;
            bottom30px;
            right0px;
        }
        .relative1{
            positionrelative;
            left50px;
            top5px;/*5 pixel acima do elmento acima*/
            background-colorseagreen;
        }
        .absolute1{
            positionabsolute;
            left350px;
            top120px;
            background-colorviolet;
        }
        .relative2{
            positionrelative;
            left250;
            top2000px;
            width200px;
            height200px;
            background-colorsalmon;
        }
        .absolute2{
            positionabsolute;
            left10px;
            top10px;
            width20px;
            height20px;
            background-colorgreenyellow;
        }
        .sticky{
            position: -webkit-sticky;/*safari*/
            positionsticky;
            background-color#777;
            top10px;
        }
    </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>

Nenhum comentário: