position_relative.rml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <rml>
  2. <head>
  3. <title>Relative position</title>
  4. <link type="text/rcss" href="../style.rcss"/>
  5. <link rel="source" href="https://drafts.csswg.org/css-position-3/#comparison" />
  6. <link rel="help" href="https://drafts.csswg.org/css-position-3/#comparison" />
  7. <meta name="description" content='Relative positioning with percent offset in different formatting contexts.' />
  8. <meta name="assert" content='The green box should be positioned immediately below the purple box, and together they should be vertically centered in the document.' />
  9. <meta name="assert" content='The colored boxes should be vertically ordered (with horizontal groups) as follows: white, yellow, purple, green, (orange, red), (blue, pink).' />
  10. <style>
  11. body {
  12. font-size: 16dp;
  13. }
  14. block {
  15. display: block;
  16. position: relative;
  17. overflow: auto;
  18. border: 2px #aaa;
  19. height: 90%; top: 5%
  20. }
  21. div, td {
  22. width: 70dp;
  23. height: 70dp;
  24. }
  25. table, flex { width: 70dp; }
  26. .absolute {
  27. position: absolute;
  28. bottom: 50%;
  29. left: 50%;
  30. }
  31. .relative {
  32. position: relative;
  33. top: 50%;
  34. left: 50%;
  35. }
  36. .over {
  37. position: relative;
  38. bottom: 200%;
  39. left: 100%;
  40. }
  41. .float { float: left; }
  42. flex { display: flex; }
  43. .white { background: #f0f0f0; }
  44. .purple { background: #88c; }
  45. .green { background: #6c6; }
  46. .yellow { background: #dd4; }
  47. .orange { background: #da2; }
  48. .red { background: #e77; }
  49. .blue { background: #5fc4dd; }
  50. .pink { background: #cb70e0; }
  51. </style>
  52. </head>
  53. <body>
  54. <block>
  55. <div class="absolute purple">Absolute</div>
  56. <div class="relative green">Relative</div>
  57. <p>
  58. <p class="relative"><span class="white">First line</span></p>
  59. Start<span id="x" class="relative yellow">Inline</span><span class="relative float yellow">Float</span>After
  60. </p>
  61. <table class="relative orange"><td>Table container</td></table>
  62. <flex class="relative blue"><div>Flex container</div></flex>
  63. <table class="relative"><td class="over red">Table cell</td></table>
  64. <flex class="relative"><div class="over pink">Flex item</div></flex>
  65. </block>
  66. <handle size_target="#document"/>
  67. </body>
  68. </rml>