forms.less 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. //
  2. // Forms
  3. // --------------------------------------------------
  4. // GENERAL STYLES
  5. // --------------
  6. // Make all forms have space below them
  7. form {
  8. margin: 0 0 @baseLineHeight;
  9. }
  10. fieldset {
  11. padding: 0;
  12. margin: 0;
  13. border: 0;
  14. }
  15. // Groups of fields with labels on top (legends)
  16. legend {
  17. display: block;
  18. width: 100%;
  19. padding: 0;
  20. margin-bottom: @baseLineHeight;
  21. font-size: @baseFontSize * 1.5;
  22. line-height: @baseLineHeight * 2;
  23. color: @grayDark;
  24. border: 0;
  25. border-bottom: 1px solid #e5e5e5;
  26. // Small
  27. small {
  28. font-size: @baseLineHeight * .75;
  29. color: @grayLight;
  30. }
  31. }
  32. // Set font for forms
  33. label,
  34. input,
  35. button,
  36. select,
  37. textarea {
  38. #font > .shorthand(@baseFontSize,normal,@baseLineHeight); // Set size, weight, line-height here
  39. }
  40. input,
  41. button,
  42. select,
  43. textarea {
  44. font-family: @baseFontFamily; // And only set font-family here for those that need it (note the missing label element)
  45. }
  46. // Identify controls by their labels
  47. label {
  48. display: block;
  49. margin-bottom: 5px;
  50. }
  51. // Form controls
  52. // -------------------------
  53. // Shared size and type resets
  54. select,
  55. textarea,
  56. input[type="text"],
  57. input[type="password"],
  58. input[type="datetime"],
  59. input[type="datetime-local"],
  60. input[type="date"],
  61. input[type="month"],
  62. input[type="time"],
  63. input[type="week"],
  64. input[type="number"],
  65. input[type="email"],
  66. input[type="url"],
  67. input[type="search"],
  68. input[type="tel"],
  69. input[type="color"],
  70. .uneditable-input {
  71. display: inline-block;
  72. height: @baseLineHeight;
  73. padding: 4px 6px;
  74. font-size: @baseFontSize;
  75. line-height: @baseLineHeight;
  76. color: @inputText;
  77. vertical-align: middle;
  78. }
  79. // Reset appearance properties for textual inputs and textarea
  80. // Declare width for legacy (can't be on input[type=*] selectors or it's too specific)
  81. input,
  82. textarea,
  83. .uneditable-input {
  84. width: 206px; // plus 12px padding and 2px border
  85. }
  86. // Reset height since textareas have rows
  87. textarea {
  88. height: auto;
  89. }
  90. // Everything else
  91. textarea,
  92. input[type="text"],
  93. input[type="password"],
  94. input[type="datetime"],
  95. input[type="datetime-local"],
  96. input[type="date"],
  97. input[type="month"],
  98. input[type="time"],
  99. input[type="week"],
  100. input[type="number"],
  101. input[type="email"],
  102. input[type="url"],
  103. input[type="search"],
  104. input[type="tel"],
  105. input[type="color"],
  106. .uneditable-input {
  107. background-color: @inputBackground;
  108. .box-shadow(inset 0 1px 1px rgba(0,0,0,.075));
  109. .transition(~"border linear .2s, box-shadow linear .2s");
  110. // Focus state
  111. &:focus {
  112. border-color: rgba(82,168,236, .8);
  113. outline: 0;
  114. outline: thin dotted \9; /* IE6-9 */
  115. .box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6)");
  116. }
  117. }
  118. // Position radios and checkboxes better
  119. input[type="radio"],
  120. input[type="checkbox"] {
  121. margin: 4px 0 0;
  122. line-height: normal;
  123. }
  124. // Reset width of input images, buttons, radios, checkboxes
  125. input[type="file"],
  126. input[type="image"],
  127. input[type="submit"],
  128. input[type="reset"],
  129. input[type="button"],
  130. input[type="radio"],
  131. input[type="checkbox"] {
  132. width: auto; // Override of generic input selector
  133. }
  134. // Set the height of select and file controls to match text inputs
  135. select,
  136. input[type="file"] {
  137. height: @inputHeight; /* In IE7, the height of the select element cannot be changed by height, only font-size */
  138. line-height: @inputHeight;
  139. }
  140. // Make select elements obey height by applying a border
  141. select {
  142. width: 220px; // default input width + 10px of padding that doesn't get applied
  143. border: 1px solid @inputBorder;
  144. background-color: @inputBackground; // Chrome on Linux and Mobile Safari need background-color
  145. }
  146. // Make multiple select elements height not fixed
  147. select[multiple],
  148. select[size] {
  149. height: auto;
  150. }
  151. // Focus for select, file, radio, and checkbox
  152. select:focus,
  153. input[type="file"]:focus,
  154. input[type="radio"]:focus,
  155. input[type="checkbox"]:focus {
  156. .tab-focus();
  157. }
  158. // Placeholder
  159. // -------------------------
  160. // Placeholder text gets special styles because when browsers invalidate entire lines if it doesn't understand a selector
  161. input,
  162. textarea {
  163. .placeholder();
  164. }
  165. // INPUT SIZES
  166. // -----------
  167. // General classes for quick sizes
  168. .input-mini { width: 60px; }
  169. .input-small { width: 90px; }
  170. .input-medium { width: 150px; }
  171. .input-large { width: 210px; }
  172. .input-xlarge { width: 270px; }
  173. .input-xxlarge { width: 530px; }
  174. // GRID SIZING FOR INPUTS
  175. // ----------------------
  176. // Grid sizes
  177. #grid > .input(@gridColumnWidth, @gridGutterWidth);
  178. // DISABLED STATE
  179. // --------------
  180. // Disabled and read-only inputs
  181. input[disabled],
  182. select[disabled],
  183. textarea[disabled],
  184. input[readonly],
  185. select[readonly],
  186. textarea[readonly] {
  187. cursor: not-allowed;
  188. background-color: @inputDisabledBackground;
  189. }
  190. // Explicitly reset the colors here
  191. input[type="radio"][disabled],
  192. input[type="checkbox"][disabled],
  193. input[type="radio"][readonly],
  194. input[type="checkbox"][readonly] {
  195. background-color: transparent;
  196. }
  197. // HTML5 invalid states
  198. // Shares styles with the .control-group.error above
  199. input:focus:invalid,
  200. textarea:focus:invalid,
  201. select:focus:invalid {
  202. color: #b94a48;
  203. border-color: #ee5f5b;
  204. &:focus {
  205. border-color: darken(#ee5f5b, 10%);
  206. @shadow: 0 0 6px lighten(#ee5f5b, 20%);
  207. .box-shadow(@shadow);
  208. }
  209. }