Advertisement
amran_87

CSS - Position Relative & Absolute

Jan 22nd, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.70 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. body {
  6.   position: relative;
  7.   top: 50px;
  8. }
  9.  
  10. div.relative {
  11.     position: relative;
  12.     border: 3px solid #73AD21;
  13. }
  14.  
  15. div.absolute {
  16.     position: absolute;
  17.     border: 3px solid blue;
  18.     top: 10px;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23.  
  24. <h2>position: static;</h2>
  25.  
  26. <p>An element with position: static; is not positioned in any special way; it is
  27. always positioned according to the normal flow of the page:</p>
  28.  
  29. <div class="relative">
  30. This div element has position: relative;
  31.  
  32.  <div class="absolute">
  33.   This div element has position: absolute;
  34.  </div>
  35.  
  36. </div>
  37.  
  38. <div class="absolute">
  39. This div element has position: absolute;
  40. </div>
  41.  
  42. </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement