You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

604 lines
15 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
  1. // stylelint-disable selector-no-qualifying-type, property-no-vendor-prefix, media-feature-name-no-vendor-prefix
  2. //
  3. // Forms
  4. // --------------------------------------------------
  5. // Normalize non-controls
  6. //
  7. // Restyle and baseline non-control form elements.
  8. fieldset {
  9. // Chrome and Firefox set a `min-width: min-content;` on fieldsets,
  10. // so we reset that to ensure it behaves more like a standard block element.
  11. // See https://github.com/twbs/bootstrap/issues/12359.
  12. min-width: 0;
  13. padding: 0;
  14. margin: 0;
  15. border: 0;
  16. }
  17. legend {
  18. display: block;
  19. width: 100%;
  20. padding: 0;
  21. margin-bottom: @line-height-computed;
  22. font-size: (@font-size-base * 1.5);
  23. line-height: inherit;
  24. color: @legend-color;
  25. border: 0;
  26. border-bottom: 1px solid @legend-border-color;
  27. }
  28. label {
  29. display: inline-block;
  30. max-width: 100%; // Force IE8 to wrap long content (see https://github.com/twbs/bootstrap/issues/13141)
  31. margin-bottom: 5px;
  32. font-weight: 700;
  33. }
  34. // Normalize form controls
  35. //
  36. // While most of our form styles require extra classes, some basic normalization
  37. // is required to ensure optimum display with or without those classes to better
  38. // address browser inconsistencies.
  39. input[type="search"] {
  40. // Override content-box in Normalize (* isn't specific enough)
  41. .box-sizing(border-box);
  42. // Search inputs in iOS
  43. //
  44. // This overrides the extra rounded corners on search inputs in iOS so that our
  45. // `.form-control` class can properly style them. Note that this cannot simply
  46. // be added to `.form-control` as it's not specific enough. For details, see
  47. // https://github.com/twbs/bootstrap/issues/11586.
  48. -webkit-appearance: none;
  49. appearance: none;
  50. }
  51. // Position radios and checkboxes better
  52. input[type="radio"],
  53. input[type="checkbox"] {
  54. margin: 4px 0 0;
  55. margin-top: 1px \9; // IE8-9
  56. line-height: normal;
  57. // Apply same disabled cursor tweak as for inputs
  58. // Some special care is needed because <label>s don't inherit their parent's `cursor`.
  59. //
  60. // Note: Neither radios nor checkboxes can be readonly.
  61. &[disabled],
  62. &.disabled,
  63. fieldset[disabled] & {
  64. cursor: @cursor-disabled;
  65. }
  66. }
  67. input[type="file"] {
  68. display: block;
  69. }
  70. // Make range inputs behave like textual form controls
  71. input[type="range"] {
  72. display: block;
  73. width: 100%;
  74. }
  75. // Make multiple select elements height not fixed
  76. select[multiple],
  77. select[size] {
  78. height: auto;
  79. }
  80. // Focus for file, radio, and checkbox
  81. input[type="file"]:focus,
  82. input[type="radio"]:focus,
  83. input[type="checkbox"]:focus {
  84. .tab-focus();
  85. }
  86. // Adjust output element
  87. output {
  88. display: block;
  89. padding-top: (@padding-base-vertical + 1);
  90. font-size: @font-size-base;
  91. line-height: @line-height-base;
  92. color: @input-color;
  93. }
  94. // Common form controls
  95. //
  96. // Shared size and type resets for form controls. Apply `.form-control` to any
  97. // of the following form controls:
  98. //
  99. // select
  100. // textarea
  101. // input[type="text"]
  102. // input[type="password"]
  103. // input[type="datetime"]
  104. // input[type="datetime-local"]
  105. // input[type="date"]
  106. // input[type="month"]
  107. // input[type="time"]
  108. // input[type="week"]
  109. // input[type="number"]
  110. // input[type="email"]
  111. // input[type="url"]
  112. // input[type="search"]
  113. // input[type="tel"]
  114. // input[type="color"]
  115. .form-control {
  116. display: block;
  117. width: 100%;
  118. height: @input-height-base; // Make inputs at least the height of their button counterpart (base line-height + padding + border)
  119. padding: @padding-base-vertical @padding-base-horizontal;
  120. font-size: @font-size-base;
  121. line-height: @line-height-base;
  122. color: @input-color;
  123. background-color: @input-bg;
  124. background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
  125. border: 1px solid @input-border;
  126. border-radius: @input-border-radius; // Note: This has no effect on <select>s in some browsers, due to the limited stylability of <select>s in CSS.
  127. .box-shadow(inset 0 1px 1px rgba(0, 0, 0, .075));
  128. // Customize the `:focus` state to imitate native WebKit styles.
  129. .form-control-focus();
  130. // Placeholder
  131. .placeholder();
  132. // Unstyle the caret on `<select>`s in IE10+.
  133. &::-ms-expand {
  134. background-color: transparent;
  135. border: 0;
  136. }
  137. // Disabled and read-only inputs
  138. //
  139. // HTML5 says that controls under a fieldset > legend:first-child won't be
  140. // disabled if the fieldset is disabled. Due to implementation difficulty, we
  141. // don't honor that edge case; we style them as disabled anyway.
  142. &[disabled],
  143. &[readonly],
  144. fieldset[disabled] & {
  145. background-color: @input-bg-disabled;
  146. opacity: 1; // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655
  147. }
  148. &[disabled],
  149. fieldset[disabled] & {
  150. cursor: @cursor-disabled;
  151. }
  152. // Reset height for `textarea`s
  153. textarea& {
  154. height: auto;
  155. }
  156. }
  157. // Special styles for iOS temporal inputs
  158. //
  159. // In Mobile Safari, setting `display: block` on temporal inputs causes the
  160. // text within the input to become vertically misaligned. As a workaround, we
  161. // set a pixel line-height that matches the given height of the input, but only
  162. // for Safari. See https://bugs.webkit.org/show_bug.cgi?id=139848
  163. //
  164. // Note that as of 9.3, iOS doesn't support `week`.
  165. @media screen and (-webkit-min-device-pixel-ratio: 0) {
  166. input[type="date"],
  167. input[type="time"],
  168. input[type="datetime-local"],
  169. input[type="month"] {
  170. &.form-control {
  171. line-height: @input-height-base;
  172. }
  173. &.input-sm,
  174. .input-group-sm & {
  175. line-height: @input-height-small;
  176. }
  177. &.input-lg,
  178. .input-group-lg & {
  179. line-height: @input-height-large;
  180. }
  181. }
  182. }
  183. // Form groups
  184. //
  185. // Designed to help with the organization and spacing of vertical forms. For
  186. // horizontal forms, use the predefined grid classes.
  187. .form-group {
  188. margin-bottom: @form-group-margin-bottom;
  189. }
  190. // Checkboxes and radios
  191. //
  192. // Indent the labels to position radios/checkboxes as hanging controls.
  193. .radio,
  194. .checkbox {
  195. position: relative;
  196. display: block;
  197. margin-top: 10px;
  198. margin-bottom: 10px;
  199. // These are used on elements with <label> descendants
  200. &.disabled,
  201. fieldset[disabled] & {
  202. label {
  203. cursor: @cursor-disabled;
  204. }
  205. }
  206. label {
  207. min-height: @line-height-computed; // Ensure the input doesn't jump when there is no text
  208. padding-left: 20px;
  209. margin-bottom: 0;
  210. font-weight: 400;
  211. cursor: pointer;
  212. }
  213. }
  214. .radio input[type="radio"],
  215. .radio-inline input[type="radio"],
  216. .checkbox input[type="checkbox"],
  217. .checkbox-inline input[type="checkbox"] {
  218. position: absolute;
  219. margin-top: 4px \9;
  220. margin-left: -20px;
  221. }
  222. .radio + .radio,
  223. .checkbox + .checkbox {
  224. margin-top: -5px; // Move up sibling radios or checkboxes for tighter spacing
  225. }
  226. // Radios and checkboxes on same line
  227. .radio-inline,
  228. .checkbox-inline {
  229. position: relative;
  230. display: inline-block;
  231. padding-left: 20px;
  232. margin-bottom: 0;
  233. font-weight: 400;
  234. vertical-align: middle;
  235. cursor: pointer;
  236. // These are used directly on <label>s
  237. &.disabled,
  238. fieldset[disabled] & {
  239. cursor: @cursor-disabled;
  240. }
  241. }
  242. .radio-inline + .radio-inline,
  243. .checkbox-inline + .checkbox-inline {
  244. margin-top: 0;
  245. margin-left: 10px; // space out consecutive inline controls
  246. }
  247. // Static form control text
  248. //
  249. // Apply class to a `p` element to make any string of text align with labels in
  250. // a horizontal form layout.
  251. .form-control-static {
  252. min-height: (@line-height-computed + @font-size-base);
  253. // Size it appropriately next to real form controls
  254. padding-top: (@padding-base-vertical + 1);
  255. padding-bottom: (@padding-base-vertical + 1);
  256. // Remove default margin from `p`
  257. margin-bottom: 0;
  258. &.input-lg,
  259. &.input-sm {
  260. padding-right: 0;
  261. padding-left: 0;
  262. }
  263. }
  264. // Form control sizing
  265. //
  266. // Build on `.form-control` with modifier classes to decrease or increase the
  267. // height and font-size of form controls.
  268. //
  269. // The `.form-group-* form-control` variations are sadly duplicated to avoid the
  270. // issue documented in https://github.com/twbs/bootstrap/issues/15074.
  271. .input-sm {
  272. .input-size(@input-height-small; @padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @input-border-radius-small);
  273. }
  274. .form-group-sm {
  275. .form-control {
  276. height: @input-height-small;
  277. padding: @padding-small-vertical @padding-small-horizontal;
  278. font-size: @font-size-small;
  279. line-height: @line-height-small;
  280. border-radius: @input-border-radius-small;
  281. }
  282. select.form-control {
  283. height: @input-height-small;
  284. line-height: @input-height-small;
  285. }
  286. textarea.form-control,
  287. select[multiple].form-control {
  288. height: auto;
  289. }
  290. .form-control-static {
  291. height: @input-height-small;
  292. min-height: (@line-height-computed + @font-size-small);
  293. padding: (@padding-small-vertical + 1) @padding-small-horizontal;
  294. font-size: @font-size-small;
  295. line-height: @line-height-small;
  296. }
  297. }
  298. .input-lg {
  299. .input-size(@input-height-large; @padding-large-vertical; @padding-large-horizontal; @font-size-large; @line-height-large; @input-border-radius-large);
  300. }
  301. .form-group-lg {
  302. .form-control {
  303. height: @input-height-large;
  304. padding: @padding-large-vertical @padding-large-horizontal;
  305. font-size: @font-size-large;
  306. line-height: @line-height-large;
  307. border-radius: @input-border-radius-large;
  308. }
  309. select.form-control {
  310. height: @input-height-large;
  311. line-height: @input-height-large;
  312. }
  313. textarea.form-control,
  314. select[multiple].form-control {
  315. height: auto;
  316. }
  317. .form-control-static {
  318. height: @input-height-large;
  319. min-height: (@line-height-computed + @font-size-large);
  320. padding: (@padding-large-vertical + 1) @padding-large-horizontal;
  321. font-size: @font-size-large;
  322. line-height: @line-height-large;
  323. }
  324. }
  325. // Form control feedback states
  326. //
  327. // Apply contextual and semantic states to individual form controls.
  328. .has-feedback {
  329. // Enable absolute positioning
  330. position: relative;
  331. // Ensure icons don't overlap text
  332. .form-control {
  333. padding-right: (@input-height-base * 1.25);
  334. }
  335. }
  336. // Feedback icon (requires .glyphicon classes)
  337. .form-control-feedback {
  338. position: absolute;
  339. top: 0;
  340. right: 0;
  341. z-index: 2; // Ensure icon is above input groups
  342. display: block;
  343. width: @input-height-base;
  344. height: @input-height-base;
  345. line-height: @input-height-base;
  346. text-align: center;
  347. pointer-events: none;
  348. }
  349. .input-lg + .form-control-feedback,
  350. .input-group-lg + .form-control-feedback,
  351. .form-group-lg .form-control + .form-control-feedback {
  352. width: @input-height-large;
  353. height: @input-height-large;
  354. line-height: @input-height-large;
  355. }
  356. .input-sm + .form-control-feedback,
  357. .input-group-sm + .form-control-feedback,
  358. .form-group-sm .form-control + .form-control-feedback {
  359. width: @input-height-small;
  360. height: @input-height-small;
  361. line-height: @input-height-small;
  362. }
  363. // Feedback states
  364. .has-success {
  365. .form-control-validation(@state-success-text; @state-success-text; @state-success-bg);
  366. }
  367. .has-warning {
  368. .form-control-validation(@state-warning-text; @state-warning-text; @state-warning-bg);
  369. }
  370. .has-error {
  371. .form-control-validation(@state-danger-text; @state-danger-text; @state-danger-bg);
  372. }
  373. // Reposition feedback icon if input has visible label above
  374. .has-feedback label {
  375. & ~ .form-control-feedback {
  376. top: (@line-height-computed + 5); // Height of the `label` and its margin
  377. }
  378. &.sr-only ~ .form-control-feedback {
  379. top: 0;
  380. }
  381. }
  382. // Help text
  383. //
  384. // Apply to any element you wish to create light text for placement immediately
  385. // below a form control. Use for general help, formatting, or instructional text.
  386. .help-block {
  387. display: block; // account for any element using help-block
  388. margin-top: 5px;
  389. margin-bottom: 10px;
  390. color: var(--text-muted);
  391. }
  392. // Inline forms
  393. //
  394. // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
  395. // forms begin stacked on extra small (mobile) devices and then go inline when
  396. // viewports reach <768px.
  397. //
  398. // Requires wrapping inputs and labels with `.form-group` for proper display of
  399. // default HTML form controls and our custom form controls (e.g., input groups).
  400. //
  401. // Heads up! This is mixin-ed into `.navbar-form` in navbars.less.
  402. .form-inline {
  403. // Kick in the inline
  404. @media (min-width: @screen-sm-min) {
  405. // Inline-block all the things for "inline"
  406. .form-group {
  407. display: inline-block;
  408. margin-bottom: 0;
  409. vertical-align: middle;
  410. }
  411. // In navbar-form, allow folks to *not* use `.form-group`
  412. .form-control {
  413. display: inline-block;
  414. width: auto; // Prevent labels from stacking above inputs in `.form-group`
  415. vertical-align: middle;
  416. }
  417. // Make static controls behave like regular ones
  418. .form-control-static {
  419. display: inline-block;
  420. }
  421. .input-group {
  422. display: inline-table;
  423. vertical-align: middle;
  424. .input-group-addon,
  425. .input-group-btn,
  426. .form-control {
  427. width: auto;
  428. }
  429. }
  430. // Input groups need that 100% width though
  431. .input-group > .form-control {
  432. width: 100%;
  433. }
  434. .control-label {
  435. margin-bottom: 0;
  436. vertical-align: middle;
  437. }
  438. // Remove default margin on radios/checkboxes that were used for stacking, and
  439. // then undo the floating of radios and checkboxes to match.
  440. .radio,
  441. .checkbox {
  442. display: inline-block;
  443. margin-top: 0;
  444. margin-bottom: 0;
  445. vertical-align: middle;
  446. label {
  447. padding-left: 0;
  448. }
  449. }
  450. .radio input[type="radio"],
  451. .checkbox input[type="checkbox"] {
  452. position: relative;
  453. margin-left: 0;
  454. }
  455. // Re-override the feedback icon.
  456. .has-feedback .form-control-feedback {
  457. top: 0;
  458. }
  459. }
  460. }
  461. // Horizontal forms
  462. //
  463. // Horizontal forms are built on grid classes and allow you to create forms with
  464. // labels on the left and inputs on the right.
  465. .form-horizontal {
  466. // Consistent vertical alignment of radios and checkboxes
  467. //
  468. // Labels also get some reset styles, but that is scoped to a media query below.
  469. .radio,
  470. .checkbox,
  471. .radio-inline,
  472. .checkbox-inline {
  473. padding-top: (@padding-base-vertical + 1); // Default padding plus a border
  474. margin-top: 0;
  475. margin-bottom: 0;
  476. }
  477. // Account for padding we're adding to ensure the alignment and of help text
  478. // and other content below items
  479. .radio,
  480. .checkbox {
  481. min-height: (@line-height-computed + (@padding-base-vertical + 1));
  482. }
  483. // Make form groups behave like rows
  484. .form-group {
  485. .make-row();
  486. }
  487. // Reset spacing and right align labels, but scope to media queries so that
  488. // labels on narrow viewports stack the same as a default form example.
  489. @media (min-width: @screen-sm-min) {
  490. .control-label {
  491. padding-top: (@padding-base-vertical + 1); // Default padding plus a border
  492. margin-bottom: 0;
  493. text-align: right;
  494. }
  495. }
  496. // Validation states
  497. //
  498. // Reposition the icon because it's now within a grid column and columns have
  499. // `position: relative;` on them. Also accounts for the grid gutter padding.
  500. .has-feedback .form-control-feedback {
  501. right: floor((@grid-gutter-width / 2));
  502. }
  503. // Form group sizes
  504. //
  505. // Quick utility class for applying `.input-lg` and `.input-sm` styles to the
  506. // inputs and labels within a `.form-group`.
  507. .form-group-lg {
  508. @media (min-width: @screen-sm-min) {
  509. .control-label {
  510. padding-top: (@padding-large-vertical + 1);
  511. font-size: @font-size-large;
  512. }
  513. }
  514. }
  515. .form-group-sm {
  516. @media (min-width: @screen-sm-min) {
  517. .control-label {
  518. padding-top: (@padding-small-vertical + 1);
  519. font-size: @font-size-small;
  520. }
  521. }
  522. }
  523. }