code_junkie

How can you customize the numbers in an ordered list?

Nov 10th, 2011
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. 1. an item
  2. // skip some items for brevity
  3. 9. another item
  4. 10. notice the 1 is under the 9, and the item contents also line up
  5.  
  6. 1) an item
  7.  
  8. <style type="text/css">
  9. li {
  10. list-style-position:inside;
  11. margin-bottom:.5em;
  12. }
  13. li span {
  14. float:left;
  15. margin-left: 2em;
  16. margin-top:-1.25em;
  17. }
  18. </style>
  19.  
  20. <ol start="8">
  21. <li><span>Item</span></li>
  22. <li><span>Item</span></li>
  23. <li><span>Item</span></li>
  24. <li><span>Item</span></li>
  25. </ol>
  26.  
  27. li {
  28. list-style-type: decimal;
  29. list-style-position: inside;
  30. }
  31.  
  32. ol { counter-reset: item }
  33. li { display: block }
  34. li:before { content: counter(item) ") "; counter-increment: item }
  35.  
  36. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  37. <html xmlns="http://www.w3.org/1999/xhtml">
  38. <head>
  39. <title> new document </title>
  40. <style type="text/css">
  41. <!--
  42. ol {
  43. counter-reset: item;
  44. margin-left: 0;
  45. padding-left: 0;
  46. }
  47. li {
  48. margin-bottom: .5em;
  49. }
  50. li:before {
  51. display: inline-block;
  52. content: counter(item, upper-roman) ")";
  53. counter-increment: item;
  54. width: 3em;
  55. }
  56. -->
  57. </style>
  58. </head>
  59.  
  60. <body>
  61. <ol>
  62. <li>One</li>
  63. <li>Two</li>
  64. <li>Three</li>
  65. <li>Four</li>
  66. <li>Five</li>
  67. <li>Six</li>
  68. <li>Seven</li>
  69. <li>Eight</li>
  70. <li>Nine</li>
  71. <li>Ten</li>
  72. </ol>
  73. </body>
  74. </html>
  75.  
  76. li:before {
  77. content: counter(item) ") ";
  78. counter-increment: item;
  79. display: marker;
  80. width: 2em;
  81. }
  82.  
  83. ol { list-style-type: decimal-leading-zero; }
  84.  
  85. <style type="text/css">
  86. <!--
  87. ol {
  88. counter-reset: item;
  89. margin-left: 0;
  90. padding-left: 0;
  91. }
  92. li {
  93. display: block;
  94. margin-bottom: .5em;
  95. margin-left: 2em;
  96. }
  97. li:before {
  98. display: inline-block;
  99. content: counter(item) ") ";
  100. counter-increment: item;
  101. width: 2em;
  102. margin-left: -2em;
  103. }
  104. -->
  105. </style>
  106. <body>
  107. <ol>
  108. <li>One</li>
  109. <li>Two</li>
  110. <li>Three</li>
  111. <li>Four</li>
  112. <li>Five</li>
  113. <li>Six</li>
  114. <li>Seven</li>
  115. <li>Eight</li>
  116. <li>Nine<br>Items</li>
  117. <li>Ten<br>Items</li>
  118. </ol>
  119.  
  120. li:before {
  121. content: counter(item, upper-roman) ") ";
  122. counter-increment: item;
  123. /* ... */
  124.  
  125. ol {
  126. counter-reset: item;
  127. margin-left: 0;
  128. padding-left: 0;
  129. }
  130.  
  131. li {
  132. display: block;
  133. margin-left: 3.5em; /* Change with margin-left on li:before. Must be -li:before::margin-left + li:before::padding-right. (Causes indention for other lines.) */
  134. }
  135.  
  136. li:before {
  137. content: counter(item) ")"; /* Change 'item' to 'item, upper-roman' or 'item, lower-roman' for upper- and lower-case roman, respectively. */
  138. counter-increment: item;
  139. display: inline-block;
  140. text-align: right;
  141. width: 3em; /* Must be the maximum width of your list's numbers, including the ')', for compatability (in case you use a fixed-width font, for example). Will have to beef up if using roman. */
  142. padding-right: 0.5em;
  143. margin-left: -3.5em; /* See li comments. */
  144. }
  145.  
  146. LI:before {
  147. display: marker;
  148. content: "(" counter(counter) ")";
  149. counter-increment: counter;
  150. width: 6em;
  151. text-align: center;
  152. }
  153.  
  154. <ol type="a">
  155. <li>Turn left on Maple Street</li>
  156. <li>Turn right on Clover Court</li>
  157. </ol>
  158.  
  159. <html>
  160. <head>
  161. <style type='text/css'>
  162.  
  163. ol { counter-reset: item; }
  164.  
  165. li { display: block; }
  166.  
  167. li:before { content: counter(item) ")"; counter-increment: item;
  168. display: inline-block; width: 50px; }
  169.  
  170. </style>
  171. </head>
  172. <body>
  173. <ol>
  174. <li>Something</li>
  175. <li>Something</li>
  176. <li>Something</li>
  177. <li>Something</li>
  178. <li>Something</li>
  179. <li>Something</li>
  180. <li>Something</li>
  181. <li>Something</li>
  182. <li>Something</li>
  183. <li>Something</li>
  184. <li>Something</li>
  185. <li>Something</li>
  186. </ol>
  187. </body>
  188.  
  189. <style type="text/css">
  190. ol {
  191. list-style-position: inside;
  192. }
  193. li:first-letter {
  194. white-space: pre;
  195. }
  196. </style>
  197.  
  198. <ol>
  199. <li> an item</li>
  200. <li> another item</li>
  201. ...
  202. </ol>
  203.  
  204. <style type="text/css">
  205. ol {
  206. list-style-position: inside;
  207. }
  208. </style>
  209.  
  210. <ol>
  211. <li><pre> </pre>an item</li>
  212. <li><pre> </pre>another item</li>
  213. ...
  214. </ol>
Add Comment
Please, Sign In to add comment