mixins.less 26 KB

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