09-21-advanced-form.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <!doctype html>
  2. <html lang="en" class="no-js">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <title>Advanced Form</title>
  7. <script src="js/modernizr.js"></script>
  8. <style>
  9. body {
  10. font-family: Avenir Next, Avenir, SegoeUI, Franklin Gothic, arial, sans-serif;
  11. background-color: #edf5f8;
  12. margin: 0;
  13. padding: 1em;
  14. }
  15. label {
  16. cursor: pointer;
  17. display: block;
  18. }
  19. button {
  20. cursor: pointer;
  21. border: 0;
  22. padding: .5em 1em;
  23. color: #fff;
  24. border-radius: .25em;
  25. font-size: 1em;
  26. background-color: #173b6d;
  27. background-image: -webkit-linear-gradient(top, #1a4a8e, #173b6d);
  28. background-image: -moz-linear-gradient(top, #1a4a8e, #173b6d);
  29. background-image: -o-linear-gradient(top, #1a4a8e, #173b6d);
  30. background-image: linear-gradient(to bottom, #1a4a8e, #173b6d);
  31. box-shadow: 0 .25em 0 rgba(23, 59, 109, 0.3), inset 0 1px 0 rgba(0, 0, 0, 0.3);
  32. }
  33. button:focus {
  34. outline: 0;
  35. background-color: #2158a9;
  36. background-image: -webkit-linear-gradient(top, #2063c0, #1d4d90);
  37. background-image: -moz-linear-gradient(top, #2063c0, #1d4d90);
  38. background-image: -o-linear-gradient(top, #2063c0, #1d4d90);
  39. background-image: linear-gradient(to bottom, #2063c0, #1d4d90);
  40. box-shadow: 0 .25em 0 rgba(23, 59, 109, 0.3),
  41. inset 0 1px 0 rgba(0, 0, 0, 0.3),
  42. 0 0 .5em rgba(93, 162, 248, 0.5);
  43. }
  44. input,
  45. textarea {
  46. font: inherit;
  47. }
  48. textarea {
  49. height: 10em;
  50. resize: vertical;
  51. }
  52. input[type="radio"] {
  53. margin-right: .75em;
  54. }
  55. legend {
  56. padding: 0 0 .5em 0;
  57. font-weight: bold;
  58. color: #777;
  59. display: table;
  60. }
  61. /**
  62. * Since fieldsets are notoriously hard to style, we'll just
  63. * remove default styles from the fieldset and style a wrapper element
  64. * instead.
  65. * 1. Bug: Safari has a weird thing where the top margin from elements after
  66. * the <legend> get shifted to the top of the fieldset. Setting a tiny
  67. * amount of padding on the <fieldset> element counters this.
  68. * 2. WebKit- and Blink-based browsers have a minimum width set to respect
  69. * the default width of input fields. We override it with min-width here.
  70. */
  71. fieldset {
  72. border: 0;
  73. padding: 0.01em 0 0 0; /* 1 */
  74. margin: 0;
  75. min-width: 0; /* 2 */
  76. }
  77. /**
  78. * Firefox browsers have a minimum width for fieldsets. The only way to
  79. * override it is to change the display mode to table-*.
  80. * The @-moz-document url-prefix() bit is a Mozilla-specific mechanism
  81. * to allow users to override site-specific styles in user stylesheets.
  82. * It works for author styles as well, so we might as well use it, even
  83. * if it's an ugly hack. Leaving the url-prefix()-bit empty applies
  84. * the rule for any URL.
  85. * Note: this adds a couple of pixels of extra white-space after the
  86. * fieldset.
  87. */
  88. @-moz-document url-prefix() {
  89. fieldset {
  90. display: table-cell;
  91. }
  92. }
  93. /**
  94. * Our "artificial fieldset" since ordinary fieldsets are a pain to style.
  95. * 1. Add a border, mostly to create a visually distinguishing edge for
  96. * old browsers like IE 8.
  97. */
  98. .fieldset-wrapper {
  99. padding: 1em;
  100. margin-bottom: 1em;
  101. border: 1px solid #eee; /* 1 */
  102. background-color: #fff;
  103. -webkit-box-shadow: 0 0 .25em rgba(0, 0, 0, 0.25);
  104. -moz-box-shadow: 0 0 .25em rgba(0, 0, 0, 0.25);
  105. box-shadow: 0 0 .25em rgba(0, 0, 0, 0.25);
  106. }
  107. /**
  108. * No border for more modern browsers (excludes old browsers that don't
  109. * understand the :root selector).
  110. */
  111. :root .fieldset-wrapper {
  112. border: 0;
  113. }
  114. .field {
  115. max-width: 20em;
  116. }
  117. .field-text label,
  118. .field-text input,
  119. .field-prefixed,
  120. .field-text textarea {
  121. width: 100%;
  122. max-width: 100%;
  123. -webkit-appearance: none;
  124. -moz-box-sizing: border-box;
  125. box-sizing: border-box;
  126. }
  127. .field-text input,
  128. .field-text textarea {
  129. padding: .375em .3125em .3125em;
  130. border: 1px solid #ccc;
  131. border-radius: .25em;
  132. }
  133. .field-text input:focus,
  134. .field-text textarea:focus {
  135. outline: 0;
  136. box-shadow: 0 0 .5em rgba(93, 162, 248, 0.5);
  137. border-color: #5da2f8;
  138. }
  139. .field-submit {
  140. padding: 1em;
  141. }
  142. .flexbox .field-prefixed {
  143. display: -webkit-flex;
  144. display: -ms-flexbox;
  145. display: -webkit-box;
  146. display: -moz-box;
  147. display: flex;
  148. }
  149. .field-prefix {
  150. display: inline-block;
  151. padding: .375em .375em .3125em .375em;
  152. background-color: #f5f8f8;
  153. color: #666f77;
  154. border: 1px solid #ccc;
  155. -moz-box-sizing: border-box;
  156. box-sizing: border-box;
  157. border-radius: .25em;
  158. }
  159. .flexbox .field-prefix {
  160. display: -webkit-flex;
  161. display: -ms-flexbox;
  162. display: -webkit-box;
  163. display: -moz-box;
  164. display: flex;
  165. border-right: 0;
  166. border-radius: .25em 0 0 .25em;
  167. -webkit-align-items: center;
  168. -ms-flex-align: center;
  169. -webkit-box-align: center;
  170. -moz-box-align: center;
  171. align-items: center;
  172. }
  173. .field-prefixed input {
  174. max-width: 12em;
  175. }
  176. .flexbox .field-prefixed input {
  177. max-width: 100%;
  178. border-radius: 0 .25em .25em 0;
  179. -webkit-flex: 1 1 100%;
  180. -ms-flex: 1 1 100%;
  181. -webkit-box-flex: 1;
  182. -moz-box-flex: 1;
  183. flex: 1 1 100%;
  184. }
  185. .checkboxes {
  186. list-style: none;
  187. padding: 0;
  188. -webkit-column-width: 10em;
  189. -moz-column-width: 10em;
  190. column-width: 10em;
  191. }
  192. .checkboxes li {
  193. min-height: 1.5em;
  194. margin-bottom: .5em;
  195. }
  196. /**
  197. * 1. Set inline block + 100% width on <li> elements, to avoid multi-column
  198. * bug where margin flows across columns in WebKit/Blink.
  199. * This selector is only recognized by WebKit/Blink.
  200. */
  201. .checkboxes li:not(*:root) {
  202. width: 100%; /* [1] */
  203. display: inline-block; /* [1] */
  204. }
  205. .checkboxes input[type="checkbox"] + label {
  206. display: inline-block;
  207. }
  208. /* only target IE9+, so to speak. */
  209. :root input[type="checkbox"] {
  210. position: absolute;
  211. overflow: hidden;
  212. width: 1px;
  213. height: 1px;
  214. clip: rect(0 0 0 0);
  215. }
  216. :root input[type="checkbox"] + label {
  217. line-height: 1.5;
  218. color: #333;
  219. padding-left: 1.5em;
  220. background-position: .125em 36%;
  221. background-repeat: no-repeat;
  222. background-size: 18px 18px;
  223. }
  224. /**
  225. * fallbacks to png for when :checked is supported but no svg support/no js.
  226. * (in effect for Android 2.X)
  227. */
  228. :root input[type="checkbox"] + label {
  229. background-image: url(images/checkbox-unchecked.png);
  230. }
  231. :root input[type="checkbox"]:checked + label {
  232. background-image: url(images/checkbox-checked.png);
  233. }
  234. :root input[type="checkbox"]:focus + label {
  235. background-image: url(images/checkbox-unchecked-focus.png);
  236. }
  237. :root input[type="checkbox"]:focus:checked + label {
  238. background-image: url(images/checkbox-checked-focus.png);
  239. }
  240. /**
  241. * Modern browsers supporting SVG will get the inline SVG as data URI:s.
  242. * The SVG file is basically raw in the URL, but encoded to escape the SVG
  243. * code.
  244. * This boosts performance by cutting the number of requests and prevents
  245. * an ugly "white flash" as the browser switches from one graphic to the next
  246. * before all images have loaded.
  247. */
  248. /* unchecked checkbox: */
  249. :root.svgasimg input[type="checkbox"] + label {
  250. background-image: url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%20width%3D%2236%22%20height%3D%2236%22%3E%3Cpath%20fill%3D%22%23fff%22%20stroke%3D%22%23ccc%22%20stroke-width%3D%222%22%20stroke-miterlimit%3D%2210%22%20d%3D%22M35%2029c0%203.3-2.7%206-6%206H7c-3.3%200-6-2.7-6-6V7c0-3.3%202.7-6%206-6h22c3.3%200%206%202.7%206%206v22z%22%2F%3E%3C%2Fsvg%3E);
  251. }
  252. /* checked checkbox: */
  253. :root.svgasimg input[type="checkbox"]:checked + label {
  254. background-image: url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%20width%3D%2236%22%20height%3D%2236%22%3E%3Cpath%20fill%3D%22%23fff%22%20stroke%3D%22%23ccc%22%20stroke-width%3D%222%22%20stroke-miterlimit%3D%2210%22%20d%3D%22M35%2029c0%203.3-2.7%206-6%206H7c-3.3%200-6-2.7-6-6V7c0-3.3%202.7-6%206-6h22c3.3%200%206%202.7%206%206v22z%22%2F%3E%3Cpath%20fill%3D%22%231A4A8E%22%20d%3D%22M26%205l5.2%206.7S19.1%2031.2%2019.1%2031.3L5%2021l4-4%209%207%208-19z%22%2F%3E%3C%2Fsvg%3E);
  255. }
  256. /* focused (but unchecked) checkbox: */
  257. :root.svgasimg input[type="checkbox"]:focus + label {
  258. color: #000;
  259. background-image: url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%20width%3D%2236%22%20height%3D%2236%22%3E%3Cpath%20fill%3D%22%23fff%22%20stroke%3D%22%235DA2F8%22%20stroke-width%3D%222%22%20stroke-miterlimit%3D%2210%22%20d%3D%22M35%2029c0%203.3-2.7%206-6%206H7c-3.3%200-6-2.7-6-6V7c0-3.3%202.7-6%206-6h22c3.3%200%206%202.7%206%206v22z%22%2F%3E%3C%2Fsvg%3E);
  260. }
  261. /* checked and focused checkbox: */
  262. :root.svgasimg input[type="checkbox"]:focus:checked + label {
  263. background-image: url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%20width%3D%2236%22%20height%3D%2236%22%3E%3Cpath%20fill%3D%22%23fff%22%20stroke%3D%22%235DA2F8%22%20stroke-width%3D%222%22%20stroke-miterlimit%3D%2210%22%20d%3D%22M35%2029c0%203.3-2.7%206-6%206H7c-3.3%200-6-2.7-6-6V7c0-3.3%202.7-6%206-6h22c3.3%200%206%202.7%206%206v22z%22%2F%3E%3Cpath%20fill%3D%22%231A4A8E%22%20d%3D%22M26%205l5.2%206.7S19.1%2031.2%2019.1%2031.3L5%2021l4-4%209%207%208-19z%22%2F%3E%3C%2Fsvg%3E);
  264. }
  265. /**
  266. * Here's the non-inlined and commented out image version with SVG files,
  267. * to explain what's going on with the dataURI strings above. (they are
  268. * in effect containing the files below:)
  269. :root input[type="checkbox"] + label {
  270. background-image: url(images/checkbox-unchecked.svg);
  271. }
  272. :root.svgasimg input[type="checkbox"]:checked + label {
  273. background-image: url(images/checkbox-checked.svg);
  274. }
  275. :root.svgasimg input[type="checkbox"]:focus + label {
  276. color: #000;
  277. background-image: url(images/checkbox-unchecked-focus.svg);
  278. }
  279. :root.svgasimg input[type="checkbox"]:focus:checked + label {
  280. background-image: url(images/checkbox-checked-focus.svg);
  281. }*/
  282. /**
  283. * Adjust the text input fields to be in line with the
  284. * labels when screens are a little wider.
  285. */
  286. @media only screen and (min-width: 35em) {
  287. .flexbox .field-text {
  288. display: -webkit-flex;
  289. display: -ms-flexbox;
  290. display: -webkit-box;
  291. display: -moz-box;
  292. display: flex;
  293. max-width: 28em;
  294. }
  295. .flexbox .field-text label {
  296. -webkit-flex: 0 0 8em;
  297. -ms-flex: 0 0 8em;
  298. -webkit-box-flex: 0;
  299. -moz-box-flex: 0;
  300. flex: 0 0 8em;
  301. display: -webkit-flex;
  302. display: -ms-flexbox;
  303. display: -webkit-box;
  304. display: -moz-box;
  305. display: flex;
  306. -webkit-align-items: center;
  307. -ms-flex-align: center;
  308. -webkit-box-align: center;
  309. -moz-box-align: center;
  310. align-items: center;
  311. }
  312. }
  313. </style>
  314. </head>
  315. <body>
  316. <h1>Job application</h1>
  317. <form id="comments_form" action="/comments/" method="post">
  318. <div class="fieldset-wrapper">
  319. <fieldset>
  320. <legend>Your contact details</legend>
  321. <p class="field field-text">
  322. <label for="applicant-name">Name:</label>
  323. <input name="applicant-name" id="applicant-name" type="text" />
  324. </p>
  325. <p class="field field-text">
  326. <label for="applicant-email">Email Address:</label>
  327. <input name="applicant-email" id="applicant-email" type="email" />
  328. </p>
  329. <p class="field field-text">
  330. <label for="applicant-twitter">Twitter handle:</label>
  331. <span class="field-prefixed">
  332. <span class="field-prefix" id="applicant-twitter-prefix" aria-label="You can omit the @">@</span>
  333. <input aria-describedby="applicant-twitter-prefix" name="applicant-twitter" id="applicant-twitter" type="text" />
  334. </span>
  335. </p>
  336. </fieldset>
  337. </div>
  338. <div class="fieldset-wrapper">
  339. <fieldset>
  340. <legend>Which languages have you mastered?</legend>
  341. <ul class="checkboxes">
  342. <li>
  343. <input type="checkbox" name="lang-as" id="lang-as">
  344. <label for="lang-as">ActionScript</label>
  345. </li>
  346. <li>
  347. <input type="checkbox" name="lang-basic" id="lang-basic">
  348. <label for="lang-basic">BASIC</span>
  349. </li>
  350. <li>
  351. <input type="checkbox" name="lang-csharp" id="lang-csharp">
  352. <label for="lang-csharp">C#</label>
  353. </li>
  354. <li>
  355. <input type="checkbox" name="lang-cplusplus" id="lang-cplusplus">
  356. <label for="lang-cplusplus">C++</label>
  357. </li>
  358. <li>
  359. <input type="checkbox" name="lang-clojure" id="lang-clojure">
  360. <label for="lang-clojure">Clojure</label>
  361. </li>
  362. <li>
  363. <input type="checkbox" name="lang-cobol" id="lang-cobol">
  364. <label for="lang-cobol">COBOL</label>
  365. </li>
  366. <li>
  367. <input type="checkbox" name="lang-css" id="lang-css">
  368. <label for="lang-css">CSS</label>
  369. </li>
  370. <li>
  371. <input type="checkbox" name="lang-haskell" id="lang-haskell">
  372. <label for="lang-haskell">Haskell</label>
  373. </li>
  374. <li>
  375. <input type="checkbox" name="lang-html" id="lang-html">
  376. <label for="lang-html">HTML</label>
  377. </li>
  378. <li>
  379. <input type="checkbox" name="lang-java" id="lang-java">
  380. <label for="lang-java">Java</label>
  381. </li>
  382. <li>
  383. <input type="checkbox" name="lang-js" id="lang-js">
  384. <label for="lang-js">JavaScript</label>
  385. </li>
  386. <li>
  387. <input type="checkbox" name="lang-objc" id="lang-objc">
  388. <label for="lang-objc">Objective-C</label>
  389. </li>
  390. <li>
  391. <input type="checkbox" name="lang-python" id="lang-python">
  392. <label for="lang-python">Python</label>
  393. </li>
  394. <li>
  395. <input type="checkbox" name="lang-ruby" id="lang-ruby">
  396. <label for="lang-ruby">Ruby</label>
  397. </li>
  398. </ul>
  399. </fieldset>
  400. </div>
  401. <p class="field-submit">
  402. <button id="submit" class="submit" name="submit" type="submit">Send application</button>
  403. </p>
  404. </form>
  405. </body>
  406. </html>