7226634f3ea00805200d3ed7d1a21c393fa311fc.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. //
  2. // Textual form controls
  3. //
  4. .form-control {
  5. display: block;
  6. width: 100%;
  7. // // Make inputs at least the height of their button counterpart (base line-height + padding + border)
  8. // height: $input-height;
  9. padding: $input-padding-y $input-padding-x;
  10. font-size: $font-size-base;
  11. line-height: $line-height;
  12. color: $input-color;
  13. background-color: $input-bg;
  14. // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214.
  15. background-image: none;
  16. border: $border-width solid $input-border;
  17. // Note: This has no effect on <select>s in some browsers, due to the limited stylability of `<select>`s in CSS.
  18. @include border-radius($input-border-radius);
  19. @include box-shadow($input-box-shadow);
  20. @include transition(border-color ease-in-out .15s, box-shadow ease-in-out .15s);
  21. // Make inputs at least the height of their button counterpart (base line-height + padding + border).
  22. // Only apply the height to textual inputs and some selcts.
  23. // &:not(textarea),
  24. // &:not(select[size]),
  25. // &:not(select[multiple]) {
  26. // height: $input-height;
  27. // }
  28. // Unstyle the caret on `<select>`s in IE10+.
  29. &::-ms-expand {
  30. background-color: transparent;
  31. border: 0;
  32. }
  33. // Customize the `:focus` state to imitate native WebKit styles.
  34. @include form-control-focus();
  35. // Placeholder
  36. &::placeholder {
  37. color: $input-color-placeholder;
  38. // Override Firefox's unusual default opacity; see https://github.com/twbs/bootstrap/pull/11526.
  39. opacity: 1;
  40. }
  41. // Disabled and read-only inputs
  42. //
  43. // HTML5 says that controls under a fieldset > legend:first-child won't be
  44. // disabled if the fieldset is disabled. Due to implementation difficulty, we
  45. // don't honor that edge case; we style them as disabled anyway.
  46. &:disabled,
  47. &[readonly],
  48. fieldset[disabled] & {
  49. background-color: $input-bg-disabled;
  50. // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655.
  51. opacity: 1;
  52. }
  53. &[disabled],
  54. fieldset[disabled] & {
  55. cursor: $cursor-disabled;
  56. }
  57. }
  58. // Make file inputs better match text inputs by forcing them to new lines.
  59. .form-control-file,
  60. .form-control-range {
  61. display: block;
  62. }
  63. //
  64. // Labels
  65. //
  66. // For use with horizontal and inline forms, when you need the label text to
  67. // align with the form controls.
  68. .form-control-label {
  69. padding: ($input-padding-y + $border-width) $input-padding-x;
  70. margin-bottom: 0; // Override the `<label>` default
  71. }
  72. // Todo: clear this up
  73. // Special styles for iOS temporal inputs
  74. //
  75. // In Mobile Safari, setting `display: block` on temporal inputs causes the
  76. // text within the input to become vertically misaligned. As a workaround, we
  77. // set a pixel line-height that matches the given height of the input, but only
  78. // for Safari. See https://bugs.webkit.org/show_bug.cgi?id=139848
  79. @media screen and (-webkit-min-device-pixel-ratio: 0) {
  80. input[type="date"],
  81. input[type="time"],
  82. input[type="datetime-local"],
  83. input[type="month"] {
  84. &.form-control {
  85. line-height: $input-height;
  86. }
  87. &.input-sm,
  88. .input-group-sm &.form-control {
  89. line-height: $input-height-sm;
  90. }
  91. &.input-lg,
  92. .input-group-lg &.form-control {
  93. line-height: $input-height-lg;
  94. }
  95. }
  96. }
  97. // Static form control text
  98. //
  99. // Apply class to an element to make any string of text align with labels in a
  100. // horizontal form layout.
  101. .form-control-static {
  102. min-height: $input-height;
  103. // Size it appropriately next to real form controls
  104. padding-top: ($input-padding-y + $border-width);
  105. padding-bottom: ($input-padding-y + $border-width);
  106. // Remove default margin from `p`
  107. margin-bottom: 0;
  108. &.form-control-sm,
  109. &.form-control-lg {
  110. padding-right: 0;
  111. padding-left: 0;
  112. }
  113. }
  114. // Form control sizing
  115. //
  116. // Build on `.form-control` with modifier classes to decrease or increase the
  117. // height and font-size of form controls.
  118. //
  119. // The `.form-group-* form-control` variations are sadly duplicated to avoid the
  120. // issue documented in https://github.com/twbs/bootstrap/issues/15074.
  121. .form-control-sm {
  122. // height: $input-height-sm;
  123. padding: $input-padding-y-sm $input-padding-x-sm;
  124. font-size: $font-size-sm;
  125. line-height: $line-height-sm;
  126. border-radius: $input-border-radius-sm;
  127. }
  128. .form-control-lg {
  129. // height: $input-height-lg;
  130. padding: $input-padding-y-lg $input-padding-x-lg;
  131. font-size: $font-size-lg;
  132. line-height: $line-height-lg;
  133. border-radius: $input-border-radius-lg;
  134. }
  135. // Form groups
  136. //
  137. // Designed to help with the organization and spacing of vertical forms. For
  138. // horizontal forms, use the predefined grid classes.
  139. .form-group {
  140. margin-bottom: $form-group-margin-bottom;
  141. }
  142. // Checkboxes and radios
  143. //
  144. // Indent the labels to position radios/checkboxes as hanging controls.
  145. .radio,
  146. .checkbox {
  147. position: relative;
  148. display: block;
  149. // margin-top: ($spacer * .75);
  150. margin-bottom: ($spacer * .75);
  151. label {
  152. padding-left: 1.25rem;
  153. margin-bottom: 0;
  154. font-weight: normal;
  155. cursor: pointer;
  156. // When there's no labels, don't position the input.
  157. input:only-child {
  158. position: static;
  159. }
  160. }
  161. }
  162. .radio input[type="radio"],
  163. .radio-inline input[type="radio"],
  164. .checkbox input[type="checkbox"],
  165. .checkbox-inline input[type="checkbox"] {
  166. position: absolute;
  167. margin-top: .25rem;
  168. // margin-top: 4px \9;
  169. margin-left: -1.25rem;
  170. }
  171. .radio + .radio,
  172. .checkbox + .checkbox {
  173. // Move up sibling radios or checkboxes for tighter spacing
  174. margin-top: -.25rem;
  175. }
  176. // Radios and checkboxes on same line
  177. .radio-inline,
  178. .checkbox-inline {
  179. position: relative;
  180. display: inline-block;
  181. padding-left: 1.25rem;
  182. margin-bottom: 0;
  183. font-weight: normal;
  184. vertical-align: middle;
  185. cursor: pointer;
  186. }
  187. .radio-inline + .radio-inline,
  188. .checkbox-inline + .checkbox-inline {
  189. margin-top: 0;
  190. margin-left: .75rem;
  191. }
  192. // Apply same disabled cursor tweak as for inputs
  193. // Some special care is needed because <label>s don't inherit their parent's `cursor`.
  194. //
  195. // Note: Neither radios nor checkboxes can be readonly.
  196. input[type="radio"],
  197. input[type="checkbox"] {
  198. &:disabled,
  199. &.disabled,
  200. fieldset[disabled] & {
  201. cursor: $cursor-disabled;
  202. }
  203. }
  204. // These classes are used directly on <label>s
  205. .radio-inline,
  206. .checkbox-inline {
  207. &.disabled,
  208. fieldset[disabled] & {
  209. cursor: $cursor-disabled;
  210. }
  211. }
  212. // These classes are used on elements with <label> descendants
  213. .radio,
  214. .checkbox {
  215. &.disabled,
  216. fieldset[disabled] & {
  217. label {
  218. cursor: $cursor-disabled;
  219. }
  220. }
  221. }
  222. // Form control feedback states
  223. //
  224. // Apply contextual and semantic states to individual form controls.
  225. .form-control-success,
  226. .form-control-warning,
  227. .form-control-error {
  228. padding-right: ($input-padding-x * 3);
  229. background-position: center right ($input-height * .25);
  230. background-size: ($input-height * .65) ($input-height * .65);
  231. background-repeat: no-repeat;
  232. }
  233. // Form validation states
  234. .has-success {
  235. @include form-control-validation(success, $brand-success);
  236. .form-control-success {
  237. background-image: url($form-icon-success);
  238. }
  239. }
  240. .has-warning {
  241. @include form-control-validation(warning, $brand-warning);
  242. .form-control-warning {
  243. background-image: url($form-icon-warning);
  244. }
  245. }
  246. .has-error {
  247. @include form-control-validation(error, $brand-danger);
  248. .form-control-error {
  249. background-image: url($form-icon-error);
  250. }
  251. }
  252. // .form-control-success {
  253. // background-image: url("#{$form-icon-success}");
  254. // border-color: $brand-success;
  255. // }
  256. //
  257. // .form-control-warning {
  258. // background-image: url("#{$form-icon-warning}");
  259. // border-color: $brand-warning;
  260. // }
  261. //
  262. // .form-control-error {
  263. // background-image: url("#{$form-icon-danger}");
  264. // border-color: $brand-danger;
  265. // }
  266. // .has-feedback {
  267. // // Enable absolute positioning
  268. // position: relative;
  269. //
  270. // // Ensure icons don't overlap text
  271. // .form-control {
  272. // padding-right: ($input-height * 1.25);
  273. // }
  274. // }
  275. // // Feedback icon
  276. // .form-control-feedback {
  277. // position: absolute;
  278. // top: 0;
  279. // right: 0;
  280. // z-index: 2; // Ensure icon is above input groups
  281. // display: block;
  282. // width: $input-height;
  283. // height: $input-height;
  284. // line-height: $input-height;
  285. // text-align: center;
  286. // pointer-events: none;
  287. // }
  288. // .input-lg + .form-control-feedback,
  289. // .input-group-lg + .form-control-feedback {
  290. // width: $input-height-lg;
  291. // height: $input-height-lg;
  292. // line-height: $input-height-lg;
  293. // }
  294. // .input-sm + .form-control-feedback,
  295. // .input-group-sm + .form-control-feedback {
  296. // width: $input-height-sm;
  297. // height: $input-height-sm;
  298. // line-height: $input-height-sm;
  299. // }
  300. //
  301. // // Form validation states
  302. // .has-success {
  303. // @include form-control-validation($state-success-text, $state-success-text, $state-success-bg);
  304. // }
  305. // .has-warning {
  306. // @include form-control-validation($state-warning-text, $state-warning-text, $state-warning-bg);
  307. // }
  308. // .has-error {
  309. // @include form-control-validation($state-danger-text, $state-danger-text, $state-danger-bg);
  310. // }
  311. //
  312. // // Reposition feedback icon if input has visible label above
  313. // .has-feedback label {
  314. //
  315. // ~ .form-control-feedback {
  316. // // TODO: redo this since we nuked the `$line-height-computed`
  317. // top: 0; // Height of the `label` and its margin
  318. // }
  319. //
  320. // &.sr-only ~ .form-control-feedback {
  321. // top: 0;
  322. // }
  323. // }
  324. // Inline forms
  325. //
  326. // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
  327. // forms begin stacked on extra small (mobile) devices and then go inline when
  328. // viewports reach <768px.
  329. //
  330. // Requires wrapping inputs and labels with `.form-group` for proper display of
  331. // default HTML form controls and our custom form controls (e.g., input groups).
  332. //
  333. // Heads up! This is mixin-ed into `.navbar-form` in navbars.less.
  334. .form-inline {
  335. // Kick in the inline
  336. @include media-breakpoint-up(sm) {
  337. // Inline-block all the things for "inline"
  338. .form-group {
  339. display: inline-block;
  340. margin-bottom: 0;
  341. vertical-align: middle;
  342. }
  343. // In navbar-form, allow folks to *not* use `.form-group`
  344. .form-control {
  345. display: inline-block;
  346. width: auto; // Prevent labels from stacking above inputs in `.form-group`
  347. vertical-align: middle;
  348. }
  349. // Make static controls behave like regular ones
  350. .form-control-static {
  351. display: inline-block;
  352. }
  353. .input-group {
  354. display: inline-table;
  355. vertical-align: middle;
  356. .input-group-addon,
  357. .input-group-btn,
  358. .form-control {
  359. width: auto;
  360. }
  361. }
  362. // Input groups need that 100% width though
  363. .input-group > .form-control {
  364. width: 100%;
  365. }
  366. .control-label {
  367. margin-bottom: 0;
  368. vertical-align: middle;
  369. }
  370. // Remove default margin on radios/checkboxes that were used for stacking, and
  371. // then undo the floating of radios and checkboxes to match.
  372. .radio,
  373. .checkbox {
  374. display: inline-block;
  375. margin-top: 0;
  376. margin-bottom: 0;
  377. vertical-align: middle;
  378. label {
  379. padding-left: 0;
  380. }
  381. }
  382. .radio input[type="radio"],
  383. .checkbox input[type="checkbox"] {
  384. position: relative;
  385. margin-left: 0;
  386. }
  387. // Re-override the feedback icon.
  388. .has-feedback .form-control-feedback {
  389. top: 0;
  390. }
  391. }
  392. }