- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Relative Positioning with CSS
Relative positioning changes the position of the HTML element relative to where it normally appears. So "left:20" adds 20 pixels to the element's LEFT position.
You can use two values top and left along with the position property to move an HTML element anywhere in the HTML document.
- Move Left - Use a negative value for left.
- Move Right - Use a positive value for left.
- Move Up - Use a negative value for top.
- Move Down - Use a positive value for top.
Example
You can try to run the following code to implement relative positioning −
<html> <head> </head> <body> <div style = "position:relative;left:80px;top:2px;background-color:yellow;"> This div has relative positioning. </div> </body> </html>
- Related Articles
- Relative Positioning in CSS
- Relative Positioning Working in CSS
- Absolute Positioning with CSS
- Fixed Positioning with CSS
- CSS Positioning Elements
- CSS positioning related properties
- Fixed Positioning in CSS
- Understanding CSS Positioning Methods
- Absolute Positioning in CSS
- Static Positioning in CSS
- Static Positioning Using CSS
- Absolute Positioning Using CSS
- Fixed Positioning Using CSS
- CSS Relative units
- CSS position: relative;

Advertisements