CSS21-t100801-vertical-align.xhtml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>CSS 2.1 Test Suite: vertical-align (on an inline-block)</title>
  5. <link rel="author" title="L. David Baron" href="https://dbaron.org/" />
  6. <link rel="author" title="Mozilla Corporation" href="http://mozilla.com/" />
  7. <link rel="help" href="http://www.w3.org/TR/CSS21/visudet.html#blockwidth" />
  8. <meta name="flags" content="" />
  9. <meta http-equiv="Content-Style-Type" content="text/css" />
  10. <style type="text/css"><![CDATA[
  11. body { width: 500px; height: 500px; margin: 0; position: relative; }
  12. body > div { position: absolute; width: 500px; }
  13. b { display:inline-block; height: 50px; width: 1px; background:green; }
  14. ]]></style>
  15. </head>
  16. <body>
  17. <!--
  18. The basic structure of this test is that each passing item will create
  19. a box 1 pixel wide and 50px tall (stretching from 100px to 150px from
  20. the top of the page). Together these items will line up to form a
  21. rectangle.
  22. This test only tests the 'top', 'bottom', 'text-top', 'text-bottom',
  23. 'baseline', <length>, and <percentage> values of 'vertical-align'. It
  24. does not test 'sub', 'super', or 'middle', and it does not test
  25. anything relative to actual font metrics.
  26. -->
  27. <!-- vertical-align: top -->
  28. <div style="top: 100px; left: 0;">
  29. <b style="vertical-align:top"></b>
  30. </div>
  31. <div style="top: 100px; left: 1px;">
  32. <b style="vertical-align:top"></b>
  33. <span style="visibility:hidden; font-size: 10px;">text</span>
  34. </div>
  35. <div style="top: 100px; left: 2px;">
  36. <b style="vertical-align:top"></b>
  37. <span style="visibility:hidden; font-size: 100px;">text</span>
  38. </div>
  39. <div style="top: 100px; right: 496px; text-align: right;">
  40. <span style="visibility:hidden; font-size: 10px;">text</span>
  41. <b style="vertical-align:top"></b>
  42. </div>
  43. <div style="top: 100px; right: 495px; text-align: right;">
  44. <span style="visibility:hidden; font-size: 100px;">text</span>
  45. <b style="vertical-align:top"></b>
  46. </div>
  47. <!-- Test behavior of the rest of the line when there's a single loose
  48. subtree with vertical-align: top. This isn't required by the spec, but
  49. test it anyway. -->
  50. <div style="top: 100px; left: 5px;">
  51. <b style="vertical-align:baseline"></b>
  52. <span style="visibility:hidden; vertical-align: top; font-size: 100px;">text</span>
  53. </div>
  54. <div style="top: 100px; left: 6px;">
  55. <b style="vertical-align:baseline"></b>
  56. <span style="visibility:hidden; vertical-align: top; font-size: 10px;">text</span>
  57. </div>
  58. <div style="top: 100px; right: 492px; text-align: right;">
  59. <span style="visibility:hidden; vertical-align: top; font-size: 100px;">text</span>
  60. <b style="vertical-align:baseline"></b>
  61. </div>
  62. <div style="top: 100px; right: 491px; text-align: right;">
  63. <span style="visibility:hidden; vertical-align: top; font-size: 10px;">text</span>
  64. <b style="vertical-align:baseline"></b>
  65. </div>
  66. <!-- Test that we align the loose subtree, not just the box (118501) -->
  67. <div style="top: 100px; left: 9px;">
  68. <span style="font-size: 10px; vertical-align: top"><b></b></span>
  69. </div>
  70. <div style="top: 100px; left: 10px;">
  71. <span style="font-size: 100px; vertical-align: top; line-height: 0;"><b style="vertical-align:text-top"></b></span>
  72. </div>
  73. <!-- vertical-align: bottom -->
  74. <div style="bottom: 350px; left: 11px;">
  75. <b style="vertical-align:bottom"></b>
  76. </div>
  77. <div style="bottom: 350px; left: 12px;">
  78. <b style="vertical-align:bottom"></b>
  79. <span style="visibility:hidden; font-size: 10px;">text</span>
  80. </div>
  81. <div style="bottom: 350px; left: 13px;">
  82. <b style="vertical-align:bottom"></b>
  83. <span style="visibility:hidden; font-size: 100px;">text</span>
  84. </div>
  85. <div style="bottom: 350px; right: 485px; text-align: right;">
  86. <span style="visibility:hidden; font-size: 10px;">text</span>
  87. <b style="vertical-align:bottom"></b>
  88. </div>
  89. <div style="bottom: 350px; right: 484px; text-align: right;">
  90. <span style="visibility:hidden; font-size: 100px;">text</span>
  91. <b style="vertical-align:bottom"></b>
  92. </div>
  93. <!-- Test behavior of the rest of the line when there's a single loose
  94. subtree with vertical-align: bottom. This isn't required by the spec, but
  95. test it anyway. -->
  96. <div style="bottom: 350px; left: 16px;">
  97. <b style="vertical-align:text-top"></b>
  98. <span style="visibility:hidden; vertical-align: bottom; font-size: 100px;">text</span>
  99. </div>
  100. <div style="bottom: 350px; left: 17px;">
  101. <b style="vertical-align:text-top"></b>
  102. <span style="visibility:hidden; vertical-align: bottom; font-size: 10px;">text</span>
  103. </div>
  104. <div style="bottom: 350px; right: 481px; text-align: right;">
  105. <span style="visibility:hidden; vertical-align: bottom; font-size: 100px;">text</span>
  106. <b style="vertical-align:text-top"></b>
  107. </div>
  108. <div style="bottom: 350px; right: 480px; text-align: right;">
  109. <span style="visibility:hidden; vertical-align: bottom; font-size: 10px;">text</span>
  110. <b style="vertical-align:text-top"></b>
  111. </div>
  112. <!-- Test that we align the loose subtree, not just the box (118501) -->
  113. <div style="bottom: 350px; left: 20px;">
  114. <span style="font-size: 10px; vertical-align: bottom"><b style="vertical-align:text-top"></b></span>
  115. </div>
  116. <div style="bottom: 350px; left: 21px;">
  117. <span style="font-size: 100px; vertical-align: bottom; line-height: 0;"><b style="vertical-align:text-bottom"></b></span>
  118. </div>
  119. <!-- test top and bottom nested within other things -->
  120. <div style="top: 100px; left: 22px;">
  121. <span style="font-size: 100px; vertical-align: text-top">
  122. <span style="font-size: 10px; vertical-align: text-bottom">
  123. <b style="vertical-align:top"></b>
  124. </span>
  125. </span>
  126. </div>
  127. <div style="bottom: 350px; left: 23px;">
  128. <span style="font-size: 100px; vertical-align: text-bottom">
  129. <span style="font-size: 10px; vertical-align: text-top">
  130. <b style="vertical-align:bottom"></b>
  131. </span>
  132. </span>
  133. </div>
  134. <!-- test top and bottom within the same box -->
  135. <div style="top: 100px; left: 24px;">
  136. <b style="vertical-align:top"></b
  137. ><b style="vertical-align:bottom"></b>
  138. </div>
  139. <div style="bottom: 350px; left: 26px; font-size: 10px">
  140. <b style="vertical-align:bottom"></b
  141. ><b style="vertical-align:top"></b
  142. ><b style="vertical-align: -10px"></b>
  143. </div>
  144. <div style="top: 100px; left: 29px; font-size: 10px">
  145. <b style="vertical-align: -10px"></b
  146. ><b style="vertical-align:top"></b
  147. ><b style="vertical-align:bottom"></b>
  148. </div>
  149. <!-- test vertical-align: length -->
  150. <div style="top: 100px; left: 32px; font-size: 10px">
  151. <b style="vertical-align: baseline; height: 40px"></b
  152. ><b style="vertical-align: 20px; height: 20px"></b
  153. ><b style="vertical-align: -10px; height: 10px; margin-left: -2px"></b
  154. ><b style="vertical-align: -10px; height: 30px"></b>
  155. </div>
  156. <!-- test vertical-align: percentage -->
  157. <div style="top: 100px; left: 34px; font-size: 10px; line-height: 10px;">
  158. <b style="vertical-align: baseline; height: 40px"></b
  159. ><b style="vertical-align: 200%; height: 20px"></b
  160. ><b style="vertical-align: -25%; height: 10px; margin-left: -2px; line-height: 40px;"></b
  161. ><b style="vertical-align: -100%; height: 30px;line-height:10px"></b>
  162. </div>
  163. <!-- test vertical-align: text-top -->
  164. <div style="top: 100px; left: 36px; font-size: 10px; line-height: 2px;">
  165. <!-- we're testing:
  166. 1) that the top of the first b's background is even with the top of
  167. the span's background, which is likewise even with the top of the
  168. line box (thanks to the b's contribution)
  169. 2) that the second b (which serves to fill the area under the span)
  170. is aligned relative to its parent, not to the line box
  171. -->
  172. <span style="background:green"
  173. ><b style="vertical-align: text-top"></b
  174. ><span style="vertical-align: -8px"
  175. ><b style="vertical-align: text-top; height: 42px"></b
  176. ></span
  177. ></span>
  178. </div>
  179. <!-- test vertical-align: text-bottom -->
  180. <div style="bottom: 350px; left: 38px; font-size: 10px; line-height: 2px;">
  181. <!-- we're testing:
  182. 1) that the bottom of the first b's background is even with the bottom of
  183. the span's background, which is likewise even with the bottom of the
  184. line box (thanks to the b's contribution)
  185. 2) that the second b (which serves to fill the area under the span)
  186. is aligned relative to its parent, not to the line box
  187. -->
  188. <span style="background:green"
  189. ><b style="vertical-align: text-bottom"></b
  190. ><span style="vertical-align: 8px"
  191. ><b style="vertical-align: text-bottom; height: 42px"></b
  192. ></span
  193. ></span>
  194. </div>
  195. </body>
  196. </html>