Relative positioning

Relative positioning

Relative positioning allows you to adjust the position of an element to its placement in the document flow using top, right, bottom, and left properties.

Code Sample:

<!DOCTYPE html>
<html>
<head>
    <style>
        .relative-box {
            position: relative;
            left: 20px;
            top: 10px;
            width: 200px;
            height: 50px;
            background-color: lightcoral;
        }
    </style>
</head>
<body>
    <div class="relative-box">This box is relatively positioned.</div>
</body>
</html>

 

logo

CSS

Relative positioning

Beginner 5 Hours

Relative positioning

Relative positioning allows you to adjust the position of an element to its placement in the document flow using top, right, bottom, and left properties.

Code Sample:

<!DOCTYPE html>
<html>
<head>
    <style>
        .relative-box {
            position: relative;
            left: 20px;
            top: 10px;
            width: 200px;
            height: 50px;
            background-color: lightcoral;
        }
    </style>
</head>
<body>
    <div class="relative-box">This box is relatively positioned.</div>
</body>
</html>

 

Similar Data Science Tutorials

Related tutotials

Frequently Asked Questions for css

line

Copyrights © 2024 letsupdateskills All rights reserved