css_position_all.html 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  5. <title>Printed document</title>
  6. <style type="text/css">
  7. body {
  8. font-family: sans-serif;
  9. font-size: 10pt;
  10. }
  11. /* These inline styles will always be active even if an alternate stylesheet is selected with the stylesheet swticher */
  12. .example {
  13. width: 400px;
  14. page-break-after: always;
  15. margin-bottom: 10em;
  16. }
  17. .div-before, .div-after {
  18. background-color: #88d;
  19. color: #000;
  20. }
  21. .div-1 {
  22. background-color: #000;
  23. color: #fff;
  24. }
  25. .div-1-padding {
  26. padding: 10px;
  27. }
  28. .div-1a {
  29. background-color: #d33;
  30. color: #fff;
  31. }
  32. .div-1b {
  33. background-color: #3d3;
  34. color: #fff;
  35. }
  36. .div-1c {
  37. background-color: #33d;
  38. color: #fff;
  39. }
  40. .example div p {
  41. margin: 0 .25em;
  42. padding: .25em 0;
  43. }
  44. #example-1 .div-1 {
  45. position: static;
  46. }
  47. #example-2 .div-1 {
  48. position: relative;
  49. top:20px;
  50. left:-40px;
  51. }
  52. #example-3 .div-1a {
  53. position:absolute;
  54. top:0;
  55. right:0;
  56. width:200px;
  57. }
  58. #example-4 .div-1 {
  59. position:relative;
  60. }
  61. #example-4 .div-1a {
  62. position:absolute;
  63. top:0;
  64. right:0;
  65. width:200px;
  66. }
  67. #example-5 .div-1 {
  68. position:relative;
  69. }
  70. #example-5 .div-1a {
  71. position:absolute;
  72. top:0;
  73. right:0;
  74. width:200px;
  75. }
  76. #example-5 .div-1b {
  77. position:absolute;
  78. top:0;
  79. left:0;
  80. width:200px;
  81. }
  82. #example-6 .div-1 {
  83. position:relative;
  84. height:250px;
  85. }
  86. #example-6 .div-1a {
  87. position:absolute;
  88. top:0;
  89. right:0;
  90. width:200px;
  91. }
  92. #example-6 .div-1b {
  93. position:absolute;
  94. top:0;
  95. left:0;
  96. width:200px;
  97. }
  98. #example-7 .div-1a {
  99. float:left;
  100. width:200px;
  101. }
  102. #example-8 .div-1a {
  103. float:left;
  104. width:150px;
  105. }
  106. #example-8 .div-1b {
  107. float:left;
  108. width:150px;
  109. }
  110. #example-9 .div-1a {
  111. float:left;
  112. width:190px;
  113. }
  114. #example-9 .div-1b {
  115. float:left;
  116. width:190px;
  117. }
  118. #example-9 .div-1c {
  119. clear:both;
  120. }
  121. </style>
  122. </head>
  123. <body>
  124. <h3>Examples from <br />http://www.barelyfitz.com/screencast/html-training/css/positioning/</h3>
  125. position: static
  126. <div id="example-1" class="example">
  127. <div class="div-before"><p>div-before</p></div>
  128. <div class="div-1">
  129. <div class="div-1-padding">
  130. <p>div-1</p>
  131. <div class="div-1a">
  132. <p>div-1a</p>
  133. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.</p>
  134. </div>
  135. <div class="div-1b">
  136. <p>div-1b</p>
  137. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit. Nam mattis, arcu ut bibendum commodo, magna nisi tincidunt tortor, quis accumsan augue ipsum id lorem.</p>
  138. </div>
  139. <div class="div-1c"><p>div-1c</p></div>
  140. </div>
  141. </div>
  142. <div class="div-after"><p>div-after</p></div>
  143. </div>
  144. position: relative
  145. <div id="example-2" class="example">
  146. <div class="div-before"><p>div-before</p></div>
  147. <div class="div-1">
  148. <div class="div-1-padding">
  149. <p>div-1</p>
  150. <div class="div-1a">
  151. <p>div-1a</p>
  152. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.</p>
  153. </div>
  154. <div class="div-1b">
  155. <p>div-1b</p>
  156. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit. Nam mattis, arcu ut bibendum commodo, magna nisi tincidunt tortor, quis accumsan augue ipsum id lorem.</p>
  157. </div>
  158. <div class="div-1c"><p>div-1c</p></div>
  159. </div>
  160. </div>
  161. <div class="div-after"><p>div-after</p></div>
  162. </div>
  163. position: absolute
  164. <div id="example-3" class="example">
  165. <div class="div-before"><p>div-before</p></div>
  166. <div class="div-1">
  167. <div class="div-1-padding">
  168. <p>div-1</p>
  169. <div class="div-1a">
  170. <p>div-1a</p>
  171. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.</p>
  172. </div>
  173. <div class="div-1b">
  174. <p>div-1b</p>
  175. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit. Nam mattis, arcu ut bibendum commodo, magna nisi tincidunt tortor, quis accumsan augue ipsum id lorem.</p>
  176. </div>
  177. <div class="div-1c"><p>div-1c</p></div>
  178. </div>
  179. </div>
  180. <div class="div-after"><p>div-after</p></div>
  181. </div>
  182. position: relative + position: absolute
  183. <div id="example-4" class="example">
  184. <div class="div-before"><p>div-before</p></div>
  185. <div class="div-1">
  186. <div class="div-1-padding">
  187. <p>div-1</p>
  188. <div class="div-1a">
  189. <p>div-1a</p>
  190. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.</p>
  191. </div>
  192. <div class="div-1b">
  193. <p>div-1b</p>
  194. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit. Nam mattis, arcu ut bibendum commodo, magna nisi tincidunt tortor, quis accumsan augue ipsum id lorem.</p>
  195. </div>
  196. <div class="div-1c"><p>div-1c</p></div>
  197. </div>
  198. </div>
  199. <div class="div-after"><p>div-after</p></div>
  200. </div>
  201. two column absolute
  202. <div id="example-5" class="example">
  203. <div class="div-before"><p>div-before</p></div>
  204. <div class="div-1">
  205. <div class="div-1-padding">
  206. <p>div-1</p>
  207. <div class="div-1a">
  208. <p>div-1a</p>
  209. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.</p>
  210. </div>
  211. <div class="div-1b">
  212. <p>div-1b</p>
  213. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit. Nam mattis, arcu ut bibendum commodo, magna nisi tincidunt tortor, quis accumsan augue ipsum id lorem.</p>
  214. </div>
  215. <div class="div-1c"><p>div-1c</p></div>
  216. </div>
  217. </div>
  218. <div class="div-after"><p>div-after</p></div>
  219. </div>
  220. two column absolute height
  221. <div id="example-6" class="example">
  222. <div class="div-before"><p>div-before</p></div>
  223. <div class="div-1">
  224. <div class="div-1-padding">
  225. <p>div-1</p>
  226. <div class="div-1a">
  227. <p>div-1a</p>
  228. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.</p>
  229. </div>
  230. <div class="div-1b">
  231. <p>div-1b</p>
  232. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit. Nam mattis, arcu ut bibendum commodo, magna nisi tincidunt tortor, quis accumsan augue ipsum id lorem.</p>
  233. </div>
  234. <div class="div-1c"><p>div-1c</p></div>
  235. </div>
  236. </div>
  237. <div class="div-after"><p>div-after</p></div>
  238. </div>
  239. float
  240. <div id="example-7" class="example">
  241. <div class="div-before"><p>div-before</p></div>
  242. <div class="div-1">
  243. <div class="div-1-padding">
  244. <p>div-1</p>
  245. <div class="div-1a">
  246. <p>div-1a</p>
  247. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.</p>
  248. </div>
  249. <div class="div-1b">
  250. <p>div-1b</p>
  251. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit. Nam mattis, arcu ut bibendum commodo, magna nisi tincidunt tortor, quis accumsan augue ipsum id lorem.</p>
  252. </div>
  253. <div class="div-1c"><p>div-1c</p></div>
  254. </div>
  255. </div>
  256. <div class="div-after"><p>div-after</p></div>
  257. </div>
  258. float columns
  259. <div id="example-8" class="example">
  260. <div class="div-before"><p>div-before</p></div>
  261. <div class="div-1">
  262. <div class="div-1-padding">
  263. <p>div-1</p>
  264. <div class="div-1a">
  265. <p>div-1a</p>
  266. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.</p>
  267. </div>
  268. <div class="div-1b">
  269. <p>div-1b</p>
  270. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit. Nam mattis, arcu ut bibendum commodo, magna nisi tincidunt tortor, quis accumsan augue ipsum id lorem.</p>
  271. </div>
  272. <div class="div-1c"><p>div-1c</p></div>
  273. </div>
  274. </div>
  275. <div class="div-after"><p>div-after</p></div>
  276. </div>
  277. float columns with clear
  278. <div id="example-9" class="example">
  279. <div class="div-before"><p>div-before</p></div>
  280. <div class="div-1">
  281. <div class="div-1-padding">
  282. <p>div-1</p>
  283. <div class="div-1a">
  284. <p>div-1a</p>
  285. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.</p>
  286. </div>
  287. <div class="div-1b">
  288. <p>div-1b</p>
  289. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit. Nam mattis, arcu ut bibendum commodo, magna nisi tincidunt tortor, quis accumsan augue ipsum id lorem.</p>
  290. </div>
  291. <div class="div-1c"><p>div-1c</p></div>
  292. </div>
  293. </div>
  294. <div class="div-after"><p>div-after</p></div>
  295. </div>
  296. </body>
  297. </html>