09-10-simple-form.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <title>Simple Form</title>
  7. <style>
  8. body {
  9. font-family: Avenir Next, Avenir, SegoeUI, Franklin Gothic, arial, sans-serif;
  10. background-color: #edf5f8;
  11. padding: 20px;
  12. }
  13. input,
  14. textarea {
  15. font: inherit;
  16. }
  17. textarea {
  18. height: 10em;
  19. resize: vertical;
  20. }
  21. input[type="radio"] {
  22. margin-right: .75em;
  23. }
  24. ::-webkit-input-placeholder {
  25. font-style: italic;
  26. }
  27. :-ms-input-placeholder {
  28. font-style: italic;
  29. }
  30. ::-moz-placeholder {
  31. font-style: italic;
  32. }
  33. button {
  34. box-sizing: border-box;
  35. cursor: pointer;
  36. border: 0;
  37. padding: .5em 1em;
  38. color: #fff;
  39. border-radius: .25em;
  40. font-size: 1em;
  41. background-color: #173b6d;
  42. background-image: -webkit-linear-gradient(top, #1a4a8e, #173b6d);
  43. background-image: -moz-linear-gradient(top, #1a4a8e, #173b6d);
  44. background-image: -o-linear-gradient(top, #1a4a8e, #173b6d);
  45. background-image: linear-gradient(to bottom, #1a4a8e, #173b6d);
  46. box-shadow: 0 .25em 0 rgba(23, 59, 109, 0.3), inset 0 1px 0 rgba(0, 0, 0, 0.3);
  47. }
  48. button:focus {
  49. outline: 0;
  50. background-color: #2158a9;
  51. background-image: -webkit-linear-gradient(top, #2063c0, #1d4d90);
  52. background-image: -moz-linear-gradient(top, #2063c0, #1d4d90);
  53. background-image: -o-linear-gradient(top, #2063c0, #1d4d90);
  54. background-image: linear-gradient(to bottom, #2063c0, #1d4d90);
  55. box-shadow: 0 .25em 0 rgba(23, 59, 109, 0.3),
  56. inset 0 1px 0 rgba(0, 0, 0, 0.3);
  57. }
  58. /**
  59. * Since fieldsets are notoriously hard to style, we'll just
  60. * remove default styles from the fieldset and style a wrapper element
  61. * instead.
  62. * 1. Bug: Safari has a weird thing where the top margin from elements after
  63. * the <legend> get shifted to the top of the fieldset. Setting a tiny
  64. * amount of padding on the <fieldset> element counters this.
  65. * 2. WebKit- and Blink-based browsers have a minimum width set to respect
  66. * the default width of input fields. We override it with min-width here.
  67. */
  68. fieldset {
  69. border: 0;
  70. padding: 0.01em 0 0 0; /* 1 */
  71. margin: 0;
  72. min-width: 0; /* 2 */
  73. }
  74. /**
  75. * Firefox browsers have a minimum width for fieldsets. The only way to
  76. * override it is to change the display mode to table-*.
  77. * The @-moz-document url-prefix() bit is a Mozilla-specific mechanism
  78. * to allow users to override site-specific styles in user stylesheets.
  79. * It works for author styles as well, so we might as well use it, even
  80. * if it's an ugly hack. Leaving the url-prefix()-bit empty applies
  81. * the rule for any URL.
  82. * Note: this adds a couple of pixels of extra white-space after the
  83. * fieldset.
  84. */
  85. @-moz-document url-prefix() {
  86. fieldset {
  87. display: table-cell;
  88. }
  89. }
  90. legend {
  91. padding: 0 0 .5em 0;
  92. font-weight: bold;
  93. color: #777;
  94. display: table;
  95. }
  96. label {
  97. cursor: pointer;
  98. }
  99. .fieldset-wrapper {
  100. padding: 1em;
  101. margin-bottom: 1em;
  102. border: 1px solid #eee; /* 1 */
  103. background-color: #fff;
  104. box-shadow: 0 0 .25em rgba(0, 0, 0, 0.25);
  105. }
  106. /**
  107. * No border for more modern browsers.
  108. */
  109. :root .fieldset-wrapper {
  110. border: 0;
  111. }
  112. .field-text label {
  113. display: block;
  114. }
  115. .field-text label,
  116. .field-text input,
  117. .field-text .form-help,
  118. .field-text textarea {
  119. width: 100%;
  120. max-width: 20em;
  121. -moz-box-sizing: border-box;
  122. box-sizing: border-box;
  123. }
  124. .field-text input,
  125. .field-text textarea {
  126. padding: .375em .3125em .3125em;
  127. border: 1px solid #ccc;
  128. border-radius: .25em;
  129. }
  130. .field-text :focus {
  131. outline: 0;
  132. box-shadow: 0 0 .5em rgba(93, 162, 248, 0.5);
  133. border-color: #5da2f8;
  134. }
  135. .field-text :invalid {
  136. border-color: #e72633;
  137. box-shadow: 0 0 .5em rgba(229, 43, 37, 0.5);
  138. }
  139. .form-help {
  140. display: block;
  141. /* hide the help by default,
  142. without hiding it from screen readers */
  143. position: absolute;
  144. overflow: hidden;
  145. width: 1px;
  146. height: 1px;
  147. clip: rect(0, 0, 0, 0);
  148. }
  149. input:focus + .form-help {
  150. padding: .5em;
  151. margin-top: .5em;
  152. border: 1px solid #e1de8a;
  153. border-radius: .25em;
  154. font-style: italic;
  155. color: #737373;
  156. background-color: #fff;
  157. position: static;
  158. width: auto;
  159. height: auto;
  160. crop: none;
  161. }
  162. .field-submit {
  163. padding: 1em;
  164. }
  165. </style>
  166. </head>
  167. <body>
  168. <h1>Leave a comment</h1>
  169. <form id="comments_form" action="/comments/" method="post">
  170. <div class="fieldset-wrapper">
  171. <fieldset>
  172. <legend>Your contact details</legend>
  173. <p class="field field-text">
  174. <label for="comment-author">Name:</label>
  175. <input name="comment-author" id="comment-author" type="text" />
  176. </p>
  177. <p class="field field-text">
  178. <label for="comment-email">Email Address:</label>
  179. <input name="comment-email" id="comment-email" type="email" />
  180. </p>
  181. <p class="field field-text">
  182. <label for="comment-url">Web Address:</label>
  183. <input name="comment-url" aria-describedby="comment-url-help" id="comment-url" type="url" placeholder="http://example.com" />
  184. <span id="comment-url-help" role="tooltip" class="form-help">Fill in your URL if you have one. Make sure to include the ”http://”-part.</span>
  185. </p>
  186. </fieldset>
  187. </div>
  188. <div class="fieldset-wrapper">
  189. <fieldset>
  190. <legend>Comments</legend>
  191. <p class="field field-text">
  192. <label for="comment-text">Message:</label>
  193. <textarea name="comment-text" id="comment-text" cols="20" rows="10"></textarea>
  194. </p>
  195. </fieldset>
  196. </div>
  197. <div class="fieldset-wrapper">
  198. <fieldset>
  199. <legend>Remember Me</legend>
  200. <p class="field">
  201. <label><input name="remember" type="radio" value="yes" />Yes</label>
  202. </p>
  203. <p class="field">
  204. <label>
  205. <input name="remember" type="radio" value="no" checked="checked" />No</label>
  206. </p>
  207. </fieldset>
  208. </div>
  209. <p class="field-submit">
  210. <button id="submit" class="submit" name="submit" type="submit">Post comment</button>
  211. </p>
  212. </form>
  213. </body>
  214. </html>