mixins.less 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. //
  2. // Mixins
  3. // --------------------------------------------------
  4. // Utilities
  5. // -------------------------
  6. // Clearfix
  7. // Source: http://nicolasgallagher.com/micro-clearfix-hack/
  8. //
  9. // For modern browsers
  10. // 1. The space content is one way to avoid an Opera bug when the
  11. // contenteditable attribute is included anywhere else in the document.
  12. // Otherwise it causes space to appear at the top and bottom of elements
  13. // that are clearfixed.
  14. // 2. The use of `table` rather than `block` is only necessary if using
  15. // `:before` to contain the top-margins of child elements.
  16. .clearfix() {
  17. &:before,
  18. &:after {
  19. content: " "; // 1
  20. display: table; // 2
  21. }
  22. &:after {
  23. clear: both;
  24. }
  25. }
  26. // WebKit-style focus
  27. .tab-focus() {
  28. // Default
  29. outline: thin dotted;
  30. // WebKit
  31. outline: 5px auto -webkit-focus-ring-color;
  32. outline-offset: -2px;
  33. }
  34. // Center-align a block level element
  35. .center-block() {
  36. display: block;
  37. margin-left: auto;
  38. margin-right: auto;
  39. }
  40. // Sizing shortcuts
  41. .size(@width; @height) {
  42. width: @width;
  43. height: @height;
  44. }
  45. .square(@size) {
  46. .size(@size; @size);
  47. }
  48. // Placeholder text
  49. .placeholder(@color: @input-color-placeholder) {
  50. &:-moz-placeholder { color: @color; } // Firefox 4-18
  51. &::-moz-placeholder { color: @color; // Firefox 19+
  52. opacity: 1; } // See https://github.com/twbs/bootstrap/pull/11526
  53. &:-ms-input-placeholder { color: @color; } // Internet Explorer 10+
  54. &::-webkit-input-placeholder { color: @color; } // Safari and Chrome
  55. }
  56. // Text overflow
  57. // Requires inline-block or block for proper styling
  58. .text-overflow() {
  59. overflow: hidden;
  60. text-overflow: ellipsis;
  61. white-space: nowrap;
  62. }
  63. // CSS image replacement
  64. //
  65. // Heads up! v3 launched with with only `.hide-text()`, but per our pattern for
  66. // mixins being reused as classes with the same name, this doesn't hold up. As
  67. // of v3.0.1 we have added `.text-hide()` and deprecated `.hide-text()`. Note
  68. // that we cannot chain the mixins together in Less, so they are repeated.
  69. //
  70. // Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757
  71. // Deprecated as of v3.0.1 (will be removed in v4)
  72. .hide-text() {
  73. font: ~"0/0" a;
  74. color: transparent;
  75. text-shadow: none;
  76. background-color: transparent;
  77. border: 0;
  78. }
  79. // New mixin to use as of v3.0.1
  80. .text-hide() {
  81. .hide-text();
  82. }
  83. // CSS3 PROPERTIES
  84. // --------------------------------------------------
  85. // Single side border-radius
  86. .border-top-radius(@radius) {
  87. border-top-right-radius: @radius;
  88. border-top-left-radius: @radius;
  89. }
  90. .border-right-radius(@radius) {
  91. border-bottom-right-radius: @radius;
  92. border-top-right-radius: @radius;
  93. }
  94. .border-bottom-radius(@radius) {
  95. border-bottom-right-radius: @radius;
  96. border-bottom-left-radius: @radius;
  97. }
  98. .border-left-radius(@radius) {
  99. border-bottom-left-radius: @radius;
  100. border-top-left-radius: @radius;
  101. }
  102. // Drop shadows
  103. .box-shadow(@shadow) {
  104. -webkit-box-shadow: @shadow; // iOS <4.3 & Android <4.1
  105. box-shadow: @shadow;
  106. }
  107. // Transitions
  108. .transition(@transition) {
  109. -webkit-transition: @transition;
  110. transition: @transition;
  111. }
  112. .transition-property(@transition-property) {
  113. -webkit-transition-property: @transition-property;
  114. transition-property: @transition-property;
  115. }
  116. .transition-delay(@transition-delay) {
  117. -webkit-transition-delay: @transition-delay;
  118. transition-delay: @transition-delay;
  119. }
  120. .transition-duration(@transition-duration) {
  121. -webkit-transition-duration: @transition-duration;
  122. transition-duration: @transition-duration;
  123. }
  124. .transition-transform(@transition) {
  125. -webkit-transition: -webkit-transform @transition;
  126. -moz-transition: -moz-transform @transition;
  127. -o-transition: -o-transform @transition;
  128. transition: transform @transition;
  129. }
  130. // Transformations
  131. .rotate(@degrees) {
  132. -webkit-transform: rotate(@degrees);
  133. -ms-transform: rotate(@degrees); // IE9+
  134. transform: rotate(@degrees);
  135. }
  136. .scale(@ratio; @ratio-y...) {
  137. -webkit-transform: scale(@ratio, @ratio-y);
  138. -ms-transform: scale(@ratio, @ratio-y); // IE9+
  139. transform: scale(@ratio, @ratio-y);
  140. }
  141. .translate(@x; @y) {
  142. -webkit-transform: translate(@x, @y);
  143. -ms-transform: translate(@x, @y); // IE9+
  144. transform: translate(@x, @y);
  145. }
  146. .skew(@x; @y) {
  147. -webkit-transform: skew(@x, @y);
  148. -ms-transform: skewX(@x) skewY(@y); // See https://github.com/twbs/bootstrap/issues/4885; IE9+
  149. transform: skew(@x, @y);
  150. }
  151. .translate3d(@x; @y; @z) {
  152. -webkit-transform: translate3d(@x, @y, @z);
  153. transform: translate3d(@x, @y, @z);
  154. }
  155. .rotateX(@degrees) {
  156. -webkit-transform: rotateX(@degrees);
  157. -ms-transform: rotateX(@degrees); // IE9+
  158. transform: rotateX(@degrees);
  159. }
  160. .rotateY(@degrees) {
  161. -webkit-transform: rotateY(@degrees);
  162. -ms-transform: rotateY(@degrees); // IE9+
  163. transform: rotateY(@degrees);
  164. }
  165. .perspective(@perspective) {
  166. -webkit-perspective: @perspective;
  167. -moz-perspective: @perspective;
  168. perspective: @perspective;
  169. }
  170. .perspective-origin(@perspective) {
  171. -webkit-perspective-origin: @perspective;
  172. -moz-perspective-origin: @perspective;
  173. perspective-origin: @perspective;
  174. }
  175. .transform-origin(@origin) {
  176. -webkit-transform-origin: @origin;
  177. -moz-transform-origin: @origin;
  178. transform-origin: @origin;
  179. }
  180. // Animations
  181. .animation(@animation) {
  182. -webkit-animation: @animation;
  183. animation: @animation;
  184. }
  185. // Backface visibility
  186. // Prevent browsers from flickering when using CSS 3D transforms.
  187. // Default value is `visible`, but can be changed to `hidden`
  188. .backface-visibility(@visibility){
  189. -webkit-backface-visibility: @visibility;
  190. -moz-backface-visibility: @visibility;
  191. backface-visibility: @visibility;
  192. }
  193. // Box sizing
  194. .box-sizing(@boxmodel) {
  195. -webkit-box-sizing: @boxmodel;
  196. -moz-box-sizing: @boxmodel;
  197. box-sizing: @boxmodel;
  198. }
  199. // User select
  200. // For selecting text on the page
  201. .user-select(@select) {
  202. -webkit-user-select: @select;
  203. -moz-user-select: @select;
  204. -ms-user-select: @select; // IE10+
  205. -o-user-select: @select;
  206. user-select: @select;
  207. }
  208. // Resize anything
  209. .resizable(@direction) {
  210. resize: @direction; // Options: horizontal, vertical, both
  211. overflow: auto; // Safari fix
  212. }
  213. // CSS3 Content Columns
  214. .content-columns(@column-count; @column-gap: @grid-gutter-width) {
  215. -webkit-column-count: @column-count;
  216. -moz-column-count: @column-count;
  217. column-count: @column-count;
  218. -webkit-column-gap: @column-gap;
  219. -moz-column-gap: @column-gap;
  220. column-gap: @column-gap;
  221. }
  222. // Optional hyphenation
  223. .hyphens(@mode: auto) {
  224. word-wrap: break-word;
  225. -webkit-hyphens: @mode;
  226. -moz-hyphens: @mode;
  227. -ms-hyphens: @mode; // IE10+
  228. -o-hyphens: @mode;
  229. hyphens: @mode;
  230. }
  231. // Opacity
  232. .opacity(@opacity) {
  233. opacity: @opacity;
  234. // IE8 filter
  235. @opacity-ie: (@opacity * 100);
  236. filter: ~"alpha(opacity=@{opacity-ie})";
  237. }
  238. // GRADIENTS
  239. // --------------------------------------------------
  240. #gradient {
  241. // Horizontal gradient, from left to right
  242. //
  243. // Creates two color stops, start and end, by specifying a color and position for each color stop.
  244. // Color stops are not available in IE9 and below.
  245. .horizontal(@start-color: #555; @end-color: #333; @start-percent: 0%; @end-percent: 100%) {
  246. background-image: -webkit-linear-gradient(left, color-stop(@start-color @start-percent), color-stop(@end-color @end-percent)); // Safari 5.1-6, Chrome 10+
  247. background-image: linear-gradient(to right, @start-color @start-percent, @end-color @end-percent); // Standard, IE10, Firefox 16+, Opera 12.10+, Safari 7+, Chrome 26+
  248. background-repeat: repeat-x;
  249. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(@start-color),argb(@end-color))); // IE9 and down
  250. }
  251. // Vertical gradient, from top to bottom
  252. //
  253. // Creates two color stops, start and end, by specifying a color and position for each color stop.
  254. // Color stops are not available in IE9 and below.
  255. .vertical(@start-color: #555; @end-color: #333; @start-percent: 0%; @end-percent: 100%) {
  256. background-image: -webkit-linear-gradient(top, @start-color @start-percent, @end-color @end-percent); // Safari 5.1-6, Chrome 10+
  257. background-image: linear-gradient(to bottom, @start-color @start-percent, @end-color @end-percent); // Standard, IE10, Firefox 16+, Opera 12.10+, Safari 7+, Chrome 26+
  258. background-repeat: repeat-x;
  259. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@start-color),argb(@end-color))); // IE9 and down
  260. }
  261. .directional(@start-color: #555; @end-color: #333; @deg: 45deg) {
  262. background-repeat: repeat-x;
  263. background-image: -webkit-linear-gradient(@deg, @start-color, @end-color); // Safari 5.1-6, Chrome 10+
  264. background-image: linear-gradient(@deg, @start-color, @end-color); // Standard, IE10, Firefox 16+, Opera 12.10+, Safari 7+, Chrome 26+
  265. }
  266. .horizontal-three-colors(@start-color: #00b3ee; @mid-color: #7a43b6; @color-stop: 50%; @end-color: #c3325f) {
  267. background-image: -webkit-linear-gradient(left, @start-color, @mid-color @color-stop, @end-color);
  268. background-image: linear-gradient(to right, @start-color, @mid-color @color-stop, @end-color);
  269. background-repeat: no-repeat;
  270. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(@start-color),argb(@end-color))); // IE9 and down, gets no color-stop at all for proper fallback
  271. }
  272. .vertical-three-colors(@start-color: #00b3ee; @mid-color: #7a43b6; @color-stop: 50%; @end-color: #c3325f) {
  273. background-image: -webkit-linear-gradient(@start-color, @mid-color @color-stop, @end-color);
  274. background-image: linear-gradient(@start-color, @mid-color @color-stop, @end-color);
  275. background-repeat: no-repeat;
  276. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@start-color),argb(@end-color))); // IE9 and down, gets no color-stop at all for proper fallback
  277. }
  278. .radial(@inner-color: #555; @outer-color: #333) {
  279. background-image: -webkit-radial-gradient(circle, @inner-color, @outer-color);
  280. background-image: radial-gradient(circle, @inner-color, @outer-color);
  281. background-repeat: no-repeat;
  282. }
  283. .striped(@color: rgba(255,255,255,.15); @angle: 45deg) {
  284. background-image: -webkit-linear-gradient(@angle, @color 25%, transparent 25%, transparent 50%, @color 50%, @color 75%, transparent 75%, transparent);
  285. background-image: linear-gradient(@angle, @color 25%, transparent 25%, transparent 50%, @color 50%, @color 75%, transparent 75%, transparent);
  286. }
  287. }
  288. // Reset filters for IE
  289. //
  290. // When you need to remove a gradient background, do not forget to use this to reset
  291. // the IE filter for IE9 and below.
  292. .reset-filter() {
  293. filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)"));
  294. }
  295. // Retina images
  296. //
  297. // Short retina mixin for setting background-image and -size
  298. .img-retina(@file-1x; @file-2x; @width-1x; @height-1x) {
  299. background-image: url("@{file-1x}");
  300. @media
  301. only screen and (-webkit-min-device-pixel-ratio: 2),
  302. only screen and ( min--moz-device-pixel-ratio: 2),
  303. only screen and ( -o-min-device-pixel-ratio: 2/1),
  304. only screen and ( min-device-pixel-ratio: 2),
  305. only screen and ( min-resolution: 192dpi),
  306. only screen and ( min-resolution: 2dppx) {
  307. background-image: url("@{file-2x}");
  308. background-size: @width-1x @height-1x;
  309. }
  310. }
  311. // Responsive image
  312. //
  313. // Keep images from scaling beyond the width of their parents.
  314. .img-responsive(@display: block;) {
  315. display: @display;
  316. max-width: 100%; // Part 1: Set a maximum relative to the parent
  317. height: auto; // Part 2: Scale the height according to the width, otherwise you get stretching
  318. }
  319. // COMPONENT MIXINS
  320. // --------------------------------------------------
  321. // Horizontal dividers
  322. // -------------------------
  323. // Dividers (basically an hr) within dropdowns and nav lists
  324. .nav-divider(@color: #e5e5e5) {
  325. height: 1px;
  326. margin: ((@line-height-computed / 2) - 1) 0;
  327. overflow: hidden;
  328. background-color: @color;
  329. }
  330. // Panels
  331. // -------------------------
  332. .panel-variant(@border; @heading-text-color; @heading-bg-color; @heading-border) {
  333. border-color: @border;
  334. & > .panel-heading {
  335. color: @heading-text-color;
  336. background-color: @heading-bg-color;
  337. border-color: @heading-border;
  338. + .panel-collapse .panel-body {
  339. border-top-color: @border;
  340. }
  341. }
  342. & > .panel-footer {
  343. + .panel-collapse .panel-body {
  344. border-bottom-color: @border;
  345. }
  346. }
  347. }
  348. // Alerts
  349. // -------------------------
  350. .alert-variant(@background; @border; @text-color) {
  351. background-color: @background;
  352. border-color: @border;
  353. color: @text-color;
  354. hr {
  355. border-top-color: darken(@border, 5%);
  356. }
  357. .alert-link {
  358. color: darken(@text-color, 10%);
  359. }
  360. }
  361. // Tables
  362. // -------------------------
  363. .table-row-variant(@state; @background) {
  364. // Exact selectors below required to override `.table-striped` and prevent
  365. // inheritance to nested tables.
  366. .table > thead > tr,
  367. .table > tbody > tr,
  368. .table > tfoot > tr {
  369. > td.@{state},
  370. > th.@{state},
  371. &.@{state} > td,
  372. &.@{state} > th {
  373. background-color: @background;
  374. }
  375. }
  376. // Hover states for `.table-hover`
  377. // Note: this is not available for cells or rows within `thead` or `tfoot`.
  378. .table-hover > tbody > tr {
  379. > td.@{state}:hover,
  380. > th.@{state}:hover,
  381. &.@{state}:hover > td,
  382. &.@{state}:hover > th {
  383. background-color: darken(@background, 5%);
  384. }
  385. }
  386. }
  387. // List Groups
  388. // -------------------------
  389. .list-group-item-variant(@state; @background; @color) {
  390. .list-group-item-@{state} {
  391. color: @color;
  392. background-color: @background;
  393. a& {
  394. color: @color;
  395. .list-group-item-heading { color: inherit; }
  396. &:hover,
  397. &:focus {
  398. color: @color;
  399. background-color: darken(@background, 5%);
  400. }
  401. &.active,
  402. &.active:hover,
  403. &.active:focus {
  404. color: #fff;
  405. background-color: @color;
  406. border-color: @color;
  407. }
  408. }
  409. }
  410. }
  411. // Button variants
  412. // -------------------------
  413. // Easily pump out default styles, as well as :hover, :focus, :active,
  414. // and disabled options for all buttons
  415. .button-variant(@color; @background; @border) {
  416. color: @color;
  417. background-color: @background;
  418. border-color: @border;
  419. &:hover,
  420. &:focus,
  421. &:active,
  422. &.active,
  423. .open .dropdown-toggle& {
  424. color: @color;
  425. background-color: darken(@background, 8%);
  426. border-color: darken(@border, 12%);
  427. }
  428. &:active,
  429. &.active,
  430. .open .dropdown-toggle& {
  431. background-image: none;
  432. }
  433. &.disabled,
  434. &[disabled],
  435. fieldset[disabled] & {
  436. &,
  437. &:hover,
  438. &:focus,
  439. &:active,
  440. &.active {
  441. background-color: @background;
  442. border-color: @border;
  443. }
  444. }
  445. .badge {
  446. color: @background;
  447. background-color: @color;
  448. }
  449. }
  450. // Button sizes
  451. // -------------------------
  452. .button-size(@padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) {
  453. padding: @padding-vertical @padding-horizontal;
  454. font-size: @font-size;
  455. line-height: @line-height;
  456. border-radius: @border-radius;
  457. }
  458. // Pagination
  459. // -------------------------
  460. .pagination-size(@padding-vertical; @padding-horizontal; @font-size; @border-radius) {
  461. > li {
  462. > a,
  463. > span {
  464. padding: @padding-vertical @padding-horizontal;
  465. font-size: @font-size;
  466. }
  467. &:first-child {
  468. > a,
  469. > span {
  470. .border-left-radius(@border-radius);
  471. }
  472. }
  473. &:last-child {
  474. > a,
  475. > span {
  476. .border-right-radius(@border-radius);
  477. }
  478. }
  479. }
  480. }
  481. // Labels
  482. // -------------------------
  483. .label-variant(@color) {
  484. background-color: @color;
  485. &[href] {
  486. &:hover,
  487. &:focus {
  488. background-color: darken(@color, 10%);
  489. }
  490. }
  491. }
  492. // Navbar vertical align
  493. // -------------------------
  494. // Vertically center elements in the navbar.
  495. // Example: an element has a height of 30px, so write out `.navbar-vertical-align(30px);` to calculate the appropriate top margin.
  496. .navbar-vertical-align(@element-height) {
  497. margin-top: ((@navbar-height - @element-height) / 2);
  498. margin-bottom: ((@navbar-height - @element-height) / 2);
  499. }
  500. // Progress bars
  501. // -------------------------
  502. .progress-bar-variant(@color) {
  503. background-color: @color;
  504. .progress-striped & {
  505. #gradient > .striped();
  506. }
  507. }
  508. // Responsive utilities
  509. // -------------------------
  510. // More easily include all the states for responsive-utilities.less.
  511. .responsive-visibility() {
  512. display: block !important;
  513. table& { display: table; }
  514. tr& { display: table-row !important; }
  515. th&,
  516. td& { display: table-cell !important; }
  517. }
  518. .responsive-invisibility() {
  519. &,
  520. tr&,
  521. th&,
  522. td& { display: none !important; }
  523. }
  524. // Grid System
  525. // -----------
  526. // Centered container element
  527. .container-fixed() {
  528. margin-right: auto;
  529. margin-left: auto;
  530. padding-left: (@grid-gutter-width / 2);
  531. padding-right: (@grid-gutter-width / 2);
  532. .clearfix();
  533. }
  534. // Creates a wrapper for a series of columns
  535. .make-row(@gutter: @grid-gutter-width) {
  536. margin-left: (@gutter / -2);
  537. margin-right: (@gutter / -2);
  538. .clearfix();
  539. }
  540. // Generate the extra small columns
  541. .make-xs-column(@columns; @gutter: @grid-gutter-width) {
  542. position: relative;
  543. float: left;
  544. width: percentage((@columns / @grid-columns));
  545. // Prevent columns from collapsing when empty
  546. min-height: 1px;
  547. // Inner gutter via padding
  548. padding-left: (@gutter / 2);
  549. padding-right: (@gutter / 2);
  550. }
  551. // Generate the small columns
  552. .make-sm-column(@columns; @gutter: @grid-gutter-width) {
  553. position: relative;
  554. // Prevent columns from collapsing when empty
  555. min-height: 1px;
  556. // Inner gutter via padding
  557. padding-left: (@gutter / 2);
  558. padding-right: (@gutter / 2);
  559. // Calculate width based on number of columns available
  560. @media (min-width: @screen-sm-min) {
  561. float: left;
  562. width: percentage((@columns / @grid-columns));
  563. }
  564. }
  565. // Generate the small column offsets
  566. .make-sm-column-offset(@columns) {
  567. @media (min-width: @screen-sm-min) {
  568. margin-left: percentage((@columns / @grid-columns));
  569. }
  570. }
  571. .make-sm-column-push(@columns) {
  572. @media (min-width: @screen-sm-min) {
  573. left: percentage((@columns / @grid-columns));
  574. }
  575. }
  576. .make-sm-column-pull(@columns) {
  577. @media (min-width: @screen-sm-min) {
  578. right: percentage((@columns / @grid-columns));
  579. }
  580. }
  581. // Generate the medium columns
  582. .make-md-column(@columns; @gutter: @grid-gutter-width) {
  583. position: relative;
  584. // Prevent columns from collapsing when empty
  585. min-height: 1px;
  586. // Inner gutter via padding
  587. padding-left: (@gutter / 2);
  588. padding-right: (@gutter / 2);
  589. // Calculate width based on number of columns available
  590. @media (min-width: @screen-md-min) {
  591. float: left;
  592. width: percentage((@columns / @grid-columns));
  593. }
  594. }
  595. // Generate the medium column offsets
  596. .make-md-column-offset(@columns) {
  597. @media (min-width: @screen-md-min) {
  598. margin-left: percentage((@columns / @grid-columns));
  599. }
  600. }
  601. .make-md-column-push(@columns) {
  602. @media (min-width: @screen-md) {
  603. left: percentage((@columns / @grid-columns));
  604. }
  605. }
  606. .make-md-column-pull(@columns) {
  607. @media (min-width: @screen-md-min) {
  608. right: percentage((@columns / @grid-columns));
  609. }
  610. }
  611. // Generate the large columns
  612. .make-lg-column(@columns; @gutter: @grid-gutter-width) {
  613. position: relative;
  614. // Prevent columns from collapsing when empty
  615. min-height: 1px;
  616. // Inner gutter via padding
  617. padding-left: (@gutter / 2);
  618. padding-right: (@gutter / 2);
  619. // Calculate width based on number of columns available
  620. @media (min-width: @screen-lg-min) {
  621. float: left;
  622. width: percentage((@columns / @grid-columns));
  623. }
  624. }
  625. // Generate the large column offsets
  626. .make-lg-column-offset(@columns) {
  627. @media (min-width: @screen-lg-min) {
  628. margin-left: percentage((@columns / @grid-columns));
  629. }
  630. }
  631. .make-lg-column-push(@columns) {
  632. @media (min-width: @screen-lg-min) {
  633. left: percentage((@columns / @grid-columns));
  634. }
  635. }
  636. .make-lg-column-pull(@columns) {
  637. @media (min-width: @screen-lg-min) {
  638. right: percentage((@columns / @grid-columns));
  639. }
  640. }
  641. // Framework grid generation
  642. //
  643. // Used only by Bootstrap to generate the correct number of grid classes given
  644. // any value of `@grid-columns`.
  645. .make-grid-columns() {
  646. // Common styles for all sizes of grid columns, widths 1-12
  647. .col(@index) when (@index = 1) { // initial
  648. @item: ~".col-xs-@{index}, .col-sm-@{index}, .col-md-@{index}, .col-lg-@{index}";
  649. .col(@index + 1, @item);
  650. }
  651. .col(@index, @list) when (@index =< @grid-columns) { // general; "=<" isn't a typo
  652. @item: ~".col-xs-@{index}, .col-sm-@{index}, .col-md-@{index}, .col-lg-@{index}";
  653. .col(@index + 1, ~"@{list}, @{item}");
  654. }
  655. .col(@index, @list) when (@index > @grid-columns) { // terminal
  656. @{list} {
  657. position: relative;
  658. // Prevent columns from collapsing when empty
  659. min-height: 1px;
  660. // Inner gutter via padding
  661. padding-left: (@grid-gutter-width / 2);
  662. padding-right: (@grid-gutter-width / 2);
  663. }
  664. }
  665. .col(1); // kickstart it
  666. }
  667. .make-grid-columns-float(@class) {
  668. .col(@index) when (@index = 1) { // initial
  669. @item: ~".col-@{class}-@{index}";
  670. .col(@index + 1, @item);
  671. }
  672. .col(@index, @list) when (@index =< @grid-columns) { // general
  673. @item: ~".col-@{class}-@{index}";
  674. .col(@index + 1, ~"@{list}, @{item}");
  675. }
  676. .col(@index, @list) when (@index > @grid-columns) { // terminal
  677. @{list} {
  678. float: left;
  679. }
  680. }
  681. .col(1); // kickstart it
  682. }
  683. .calc-grid(@index, @class, @type) when (@type = width) and (@index > 0) {
  684. .col-@{class}-@{index} {
  685. width: percentage((@index / @grid-columns));
  686. }
  687. }
  688. .calc-grid(@index, @class, @type) when (@type = push) {
  689. .col-@{class}-push-@{index} {
  690. left: percentage((@index / @grid-columns));
  691. }
  692. }
  693. .calc-grid(@index, @class, @type) when (@type = pull) {
  694. .col-@{class}-pull-@{index} {
  695. right: percentage((@index / @grid-columns));
  696. }
  697. }
  698. .calc-grid(@index, @class, @type) when (@type = offset) {
  699. .col-@{class}-offset-@{index} {
  700. margin-left: percentage((@index / @grid-columns));
  701. }
  702. }
  703. // Basic looping in LESS
  704. .make-grid(@index, @class, @type) when (@index >= 0) {
  705. .calc-grid(@index, @class, @type);
  706. // next iteration
  707. .make-grid(@index - 1, @class, @type);
  708. }
  709. // Form validation states
  710. //
  711. // Used in forms.less to generate the form validation CSS for warnings, errors,
  712. // and successes.
  713. .form-control-validation(@text-color: #555; @border-color: #ccc; @background-color: #f5f5f5) {
  714. // Color the label and help text
  715. .help-block,
  716. .control-label,
  717. .radio,
  718. .checkbox,
  719. .radio-inline,
  720. .checkbox-inline {
  721. color: @text-color;
  722. }
  723. // Set the border and box shadow on specific inputs to match
  724. .form-control {
  725. border-color: @border-color;
  726. .box-shadow(inset 0 1px 1px rgba(0,0,0,.075)); // Redeclare so transitions work
  727. &:focus {
  728. border-color: darken(@border-color, 10%);
  729. @shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px lighten(@border-color, 20%);
  730. .box-shadow(@shadow);
  731. }
  732. }
  733. // Set validation states also for addons
  734. .input-group-addon {
  735. color: @text-color;
  736. border-color: @border-color;
  737. background-color: @background-color;
  738. }
  739. }
  740. // Form control focus state
  741. //
  742. // Generate a customized focus state and for any input with the specified color,
  743. // which defaults to the `@input-focus-border` variable.
  744. //
  745. // We highly encourage you to not customize the default value, but instead use
  746. // this to tweak colors on an as-needed basis. This aesthetic change is based on
  747. // WebKit's default styles, but applicable to a wider range of browsers. Its
  748. // usability and accessibility should be taken into account with any change.
  749. //
  750. // Example usage: change the default blue border and shadow to white for better
  751. // contrast against a dark gray background.
  752. .form-control-focus(@color: @input-border-focus) {
  753. @color-rgba: rgba(red(@color), green(@color), blue(@color), .6);
  754. &:focus {
  755. border-color: @color;
  756. outline: 0;
  757. .box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px @{color-rgba}");
  758. }
  759. }
  760. // Form control sizing
  761. //
  762. // Relative text size, padding, and border-radii changes for form controls. For
  763. // horizontal sizing, wrap controls in the predefined grid classes. `<select>`
  764. // element gets special love because it's special, and that's a fact!
  765. .input-size(@input-height; @padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) {
  766. height: @input-height;
  767. padding: @padding-vertical @padding-horizontal;
  768. font-size: @font-size;
  769. line-height: @line-height;
  770. border-radius: @border-radius;
  771. select& {
  772. height: @input-height;
  773. line-height: @input-height;
  774. }
  775. textarea& {
  776. height: auto;
  777. }
  778. }