mixins.less 29 KB

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