CSS Position relative

Please Share On:

Definition:

CSS position:relative is positioned relative to its normal position.

The properties top, bottom, left and right will positioned the relative elements.

See an example below of using CSS position:relative;

Syntax:

position: relative;

Source Code:

See an example of relative positioned of element in top left corner with values.

<!DOCTYPE html>
<html>
<head>
<style>
.relative {
  position: relative;
  left: 50px;
  top: 20px;
  width: 400px;
  height: 80px;
  padding-left: 10px;
  border: 3px solid #73AD21;
  text-align:center;
} 

</style>
</head>
<body>
 
<h3>CSS position: relative.</h3>
 
<div class="relative">I am an element with relative position.
 
 
</body>
</html>

Output:




You may be interested in the following topics:

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright @2023. All Right Reserved.


Social media & sharing icons powered by UltimatelySocial