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> |
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> |
Copyrights © 2024 letsupdateskills All rights reserved