Relative Positioning in CSS

CSSWeb DevelopmentFront End Technology

With relative positioning, the element is positioned relative to its normal position. For this, use position: relative

Example

Let us now see an example −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
div.demo {
   position: relative;
   color: white;
   background-color: orange;
   border: 2px dashed blue;
   left: 50px;
}
</style>
</head>
<body>
<h2>Demo Heading</h2>
<p>This is demo text.</p>
<p>This is demo text.</p>
<div class="demo">
position: relative;
</div>
<p>This is another demo text.</p>
</body>
</html>

Output

raja
Published on 30-Dec-2019 17:13:16
Advertisements