Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Positioning context</title>
  6.  
  7. <style>
  8. body {
  9. width: 500px;
  10. height: 1400px;
  11. margin: 0 auto;
  12. }
  13.  
  14. h1 {
  15. text-align: center;
  16. position: fixed;
  17. top: 0;
  18. width: 480px;
  19. background-color: royalblue;
  20. padding: 5px 0 5px 0;
  21. margin: 0 auto;
  22. }
  23.  
  24. p {
  25. background: aqua;
  26. border: 3px solid blue;
  27. padding: 10px;
  28. margin: 10px;
  29. }
  30.  
  31. span {
  32. background: red;
  33. border: 1px solid black;
  34. }
  35.  
  36. p:nth-of-type(1) {
  37. margin-top: 60px;
  38. }
  39.  
  40. </style>
  41. </head>
  42. <body>
  43. <h1>Positioning context</h1>
  44.  
  45. <p>I am a basic block level element. My adjacent block level elements sit on new lines below me.</p>
  46.  
  47. <p class="positioned">Now I'm absolutely positioned relative to the <code>&lt;body&gt;</code> element, not the <code>&lt;html&gt;</code> element!</p>
  48.  
  49. <p>We are separated by our margins. Because of margin collapsing, we are separated by the width of one of our margins, not both.</p>
  50.  
  51. <p>inline elements <span>like this one</span> and <span>this one</span> sit on the same line as one another, and adjacent text nodes, if there is space on the same line. Overflowing inline elements <span>wrap onto a new line if possible — like this one containing text</span>, or just go on to a new line if not, much like this image will do: <img src="long.jpg"></p>
  52.  
  53. </body>
  54. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement