Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 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. div {
  15. position: fixed;
  16. top: 0;
  17. width: 500px;
  18. }
  19.  
  20. h1 {
  21. text-align: center;
  22. margin: 0 auto;
  23.  
  24. background-color: royalblue;
  25. padding: 5px 0 5px 0;
  26.  
  27. }
  28.  
  29. p {
  30. background: aqua;
  31. border: 3px solid blue;
  32. padding: 10px;
  33. margin: 10px;
  34. }
  35.  
  36. span {
  37. background: red;
  38. border: 1px solid black;
  39. }
  40.  
  41. p:nth-of-type(1) {
  42. margin-top: 60px;
  43. }
  44.  
  45. </style>
  46. </head>
  47. <body>
  48.  
  49. <div><h1>Positioning context</h1></div>
  50.  
  51.  
  52. <p>I am a basic block level element. My adjacent block level elements sit on new lines below me.</p>
  53.  
  54. <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>
  55.  
  56. <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>
  57.  
  58. <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>
  59.  
  60. </body>
  61. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement