mixins.less 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149
  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. .alert-btn(@background) {
  559. background-color: darken(@background, 16%);
  560. &:hover,
  561. &:focus,
  562. &:active,
  563. &.active,
  564. &.checked,
  565. .open .dropdown-toggle& {
  566. background-color: darken(@background, 24%);
  567. }
  568. }
  569. .button-variant(@color; @background; @border) {
  570. color: @color;
  571. background-color: @background;
  572. border-color: @border;
  573. .alert & {
  574. .alert-btn(@background);
  575. }
  576. &:hover,
  577. &:focus,
  578. &:active,
  579. &.active,
  580. &.checked,
  581. .open .dropdown-toggle& {
  582. color: @color;
  583. background-color: darken(@background, 8%);
  584. border-color: darken(@border, 12%);
  585. }
  586. &:active,
  587. &.active,
  588. .open .dropdown-toggle& {
  589. background-image: none;
  590. }
  591. &.disabled,
  592. &[disabled],
  593. fieldset[disabled] & {
  594. &,
  595. &:hover,
  596. &:focus,
  597. &:active,
  598. &.active {
  599. background-color: @background;
  600. border-color: @border;
  601. }
  602. }
  603. .badge {
  604. color: @background;
  605. background-color: @color;
  606. }
  607. }
  608. .button-outline-variant(@color) {
  609. color: @color;
  610. background-color: transparent;
  611. border-color: @color;
  612. .alert & {
  613. background-color: transparent;
  614. }
  615. &:hover,
  616. &:focus,
  617. &:active,
  618. &.active,
  619. &.checked,
  620. .open .dropdown-toggle& {
  621. color: @color;
  622. background-color: transparent;
  623. border-color: darken(@color, 12%);
  624. .alert & {
  625. background-color: transparent;
  626. }
  627. }
  628. &:active,
  629. &.active,
  630. .open .dropdown-toggle& {
  631. background-image: none;
  632. }
  633. &.disabled,
  634. &[disabled],
  635. fieldset[disabled] & {
  636. &,
  637. &:hover,
  638. &:focus,
  639. &:active,
  640. &.active {
  641. background-color: transparent;
  642. border-color: @color;
  643. }
  644. }
  645. .badge {
  646. color: transparent;
  647. background-color: @color;
  648. }
  649. }
  650. // Button sizes
  651. // -------------------------
  652. .button-size(@padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) {
  653. // Remove 1px to make up for the extra px of border-bottom we've added
  654. padding: @padding-vertical - 1 @padding-horizontal @padding-vertical;
  655. font-size: @font-size;
  656. line-height: @line-height;
  657. border-radius: @border-radius;
  658. }
  659. // Pagination
  660. // -------------------------
  661. .pagination-size(@padding-vertical; @padding-horizontal; @font-size; @border-radius) {
  662. > li {
  663. > a,
  664. > span {
  665. padding: @padding-vertical @padding-horizontal;
  666. font-size: @font-size;
  667. }
  668. &:first-child {
  669. > a,
  670. > span {
  671. .border-left-radius(@border-radius);
  672. }
  673. }
  674. &:last-child {
  675. > a,
  676. > span {
  677. .border-right-radius(@border-radius);
  678. }
  679. }
  680. }
  681. }
  682. // Labels
  683. // -------------------------
  684. .label-variant(@color) {
  685. background-color: @color;
  686. &[href] {
  687. &:hover,
  688. &:focus {
  689. background-color: darken(@color, 10%);
  690. }
  691. }
  692. }
  693. // Contextual backgrounds
  694. // -------------------------
  695. .bg-variant(@color) {
  696. background-color: @color;
  697. a&:hover {
  698. background-color: darken(@color, 10%);
  699. }
  700. }
  701. // Typography
  702. // -------------------------
  703. .text-emphasis-variant(@color) {
  704. color: @color;
  705. a&:hover {
  706. color: darken(@color, 10%);
  707. }
  708. }
  709. // Navbar vertical align
  710. // -------------------------
  711. // Vertically center elements in the navbar.
  712. // Example: an element has a height of 30px, so write out `.navbar-vertical-align(30px);` to calculate the appropriate top margin.
  713. .navbar-vertical-align(@element-height) {
  714. margin-top: ((@navbar-height - @element-height) / 2);
  715. margin-bottom: ((@navbar-height - @element-height) / 2);
  716. }
  717. // Progress bars
  718. // -------------------------
  719. .progress-bar-variant(@color) {
  720. background-color: @color;
  721. .progress-striped & {
  722. #gradient > .striped();
  723. }
  724. }
  725. // Responsive utilities
  726. // -------------------------
  727. // More easily include all the states for responsive-utilities.less.
  728. .responsive-visibility() {
  729. display: block !important;
  730. table& {
  731. display: table;
  732. }
  733. tr& {
  734. display: table-row !important;
  735. }
  736. th&,
  737. td& {
  738. display: table-cell !important;
  739. }
  740. }
  741. .responsive-invisibility() {
  742. display: none !important;
  743. }
  744. // Grid System
  745. // -----------
  746. // Centered container element
  747. .container-fixed() {
  748. margin-right: auto;
  749. margin-left: auto;
  750. padding-left: (@grid-gutter-width / 2);
  751. padding-right: (@grid-gutter-width / 2);
  752. &:extend(.clearfix all);
  753. }
  754. // Creates a wrapper for a series of columns
  755. .make-row(@gutter: @grid-gutter-width) {
  756. margin-left: (@gutter / -2);
  757. margin-right: (@gutter / -2);
  758. &:extend(.clearfix all);
  759. }
  760. // Generate the extra small columns
  761. .make-xs-column(@columns; @gutter: @grid-gutter-width) {
  762. position: relative;
  763. float: left;
  764. width: percentage((@columns / @grid-columns));
  765. min-height: 1px;
  766. padding-left: (@gutter / 2);
  767. padding-right: (@gutter / 2);
  768. }
  769. .make-xs-column-offset(@columns) {
  770. @media (min-width: @screen-xs-min) {
  771. margin-left: percentage((@columns / @grid-columns));
  772. }
  773. }
  774. .make-xs-column-push(@columns) {
  775. @media (min-width: @screen-xs-min) {
  776. left: percentage((@columns / @grid-columns));
  777. }
  778. }
  779. .make-xs-column-pull(@columns) {
  780. @media (min-width: @screen-xs-min) {
  781. right: percentage((@columns / @grid-columns));
  782. }
  783. }
  784. // Generate the small columns
  785. .make-sm-column(@columns; @gutter: @grid-gutter-width) {
  786. position: relative;
  787. min-height: 1px;
  788. padding-left: (@gutter / 2);
  789. padding-right: (@gutter / 2);
  790. @media (min-width: @screen-sm-min) {
  791. float: left;
  792. width: percentage((@columns / @grid-columns));
  793. }
  794. }
  795. .make-sm-column-offset(@columns) {
  796. @media (min-width: @screen-sm-min) {
  797. margin-left: percentage((@columns / @grid-columns));
  798. }
  799. }
  800. .make-sm-column-push(@columns) {
  801. @media (min-width: @screen-sm-min) {
  802. left: percentage((@columns / @grid-columns));
  803. }
  804. }
  805. .make-sm-column-pull(@columns) {
  806. @media (min-width: @screen-sm-min) {
  807. right: percentage((@columns / @grid-columns));
  808. }
  809. }
  810. // Generate the medium columns
  811. .make-md-column(@columns; @gutter: @grid-gutter-width) {
  812. position: relative;
  813. min-height: 1px;
  814. padding-left: (@gutter / 2);
  815. padding-right: (@gutter / 2);
  816. @media (min-width: @screen-md-min) {
  817. float: left;
  818. width: percentage((@columns / @grid-columns));
  819. }
  820. }
  821. .make-md-column-offset(@columns) {
  822. @media (min-width: @screen-md-min) {
  823. margin-left: percentage((@columns / @grid-columns));
  824. }
  825. }
  826. .make-md-column-push(@columns) {
  827. @media (min-width: @screen-md-min) {
  828. left: percentage((@columns / @grid-columns));
  829. }
  830. }
  831. .make-md-column-pull(@columns) {
  832. @media (min-width: @screen-md-min) {
  833. right: percentage((@columns / @grid-columns));
  834. }
  835. }
  836. // Generate the large columns
  837. .make-lg-column(@columns; @gutter: @grid-gutter-width) {
  838. position: relative;
  839. min-height: 1px;
  840. padding-left: (@gutter / 2);
  841. padding-right: (@gutter / 2);
  842. @media (min-width: @screen-lg-min) {
  843. float: left;
  844. width: percentage((@columns / @grid-columns));
  845. }
  846. }
  847. .make-lg-column-offset(@columns) {
  848. @media (min-width: @screen-lg-min) {
  849. margin-left: percentage((@columns / @grid-columns));
  850. }
  851. }
  852. .make-lg-column-push(@columns) {
  853. @media (min-width: @screen-lg-min) {
  854. left: percentage((@columns / @grid-columns));
  855. }
  856. }
  857. .make-lg-column-pull(@columns) {
  858. @media (min-width: @screen-lg-min) {
  859. right: percentage((@columns / @grid-columns));
  860. }
  861. }
  862. // Framework grid generation
  863. //
  864. // Used only by Bootstrap to generate the correct number of grid classes given
  865. // any value of `@grid-columns`.
  866. .make-grid-columns() {
  867. // Common styles for all sizes of grid columns, widths 1-12
  868. .col(@index) when (@index = 1) {
  869. // initial
  870. @item: ~'.col-xs-@{index}, .col-sm-@{index}, .col-md-@{index}, .col-lg-@{index}';
  871. .col((@index + 1), @item);
  872. }
  873. .col(@index, @list) when (@index =< @grid-columns) {
  874. // general; "=<" isn't a typo
  875. @item: ~'.col-xs-@{index}, .col-sm-@{index}, .col-md-@{index}, .col-lg-@{index}';
  876. .col((@index + 1), ~'@{list}, @{item}');
  877. }
  878. .col(@index, @list) when (@index > @grid-columns) {
  879. // terminal
  880. @{list} {
  881. position: relative;
  882. // Prevent columns from collapsing when empty
  883. min-height: 1px;
  884. // Inner gutter via padding
  885. padding-left: (@grid-gutter-width / 2);
  886. padding-right: (@grid-gutter-width / 2);
  887. }
  888. }
  889. .col(1); // kickstart it
  890. }
  891. .float-grid-columns(@class) {
  892. .col(@index) when (@index = 1) {
  893. // initial
  894. @item: ~'.col-@{class}-@{index}';
  895. .col((@index + 1), @item);
  896. }
  897. .col(@index, @list) when (@index =< @grid-columns) {
  898. // general
  899. @item: ~'.col-@{class}-@{index}';
  900. .col((@index + 1), ~'@{list}, @{item}');
  901. }
  902. .col(@index, @list) when (@index > @grid-columns) {
  903. // terminal
  904. @{list} {
  905. float: left;
  906. }
  907. }
  908. .col(1); // kickstart it
  909. }
  910. .calc-grid-column(@index, @class, @type) when (@type = width) and (@index > 0) {
  911. .col-@{class}-@{index} {
  912. width: percentage((@index / @grid-columns));
  913. }
  914. }
  915. .calc-grid-column(@index, @class, @type) when (@type = push) {
  916. .col-@{class}-push-@{index} {
  917. left: percentage((@index / @grid-columns));
  918. }
  919. }
  920. .calc-grid-column(@index, @class, @type) when (@type = pull) {
  921. .col-@{class}-pull-@{index} {
  922. right: percentage((@index / @grid-columns));
  923. }
  924. }
  925. .calc-grid-column(@index, @class, @type) when (@type = offset) {
  926. .col-@{class}-offset-@{index} {
  927. margin-left: percentage((@index / @grid-columns));
  928. }
  929. }
  930. // Basic looping in LESS
  931. .loop-grid-columns(@index, @class, @type) when (@index >= 0) {
  932. .calc-grid-column(@index, @class, @type);
  933. // next iteration
  934. .loop-grid-columns((@index - 1), @class, @type);
  935. }
  936. // Create grid for specific class
  937. .make-grid(@class) {
  938. .float-grid-columns(@class);
  939. .loop-grid-columns(@grid-columns, @class, width);
  940. .loop-grid-columns(@grid-columns, @class, pull);
  941. .loop-grid-columns(@grid-columns, @class, push);
  942. .loop-grid-columns(@grid-columns, @class, offset);
  943. }
  944. // Form validation states
  945. //
  946. // Used in forms.less to generate the form validation CSS for warnings, errors,
  947. // and successes.
  948. .form-control-validation(@text-color: #555; @border-color: #ccc; @background-color: #f5f5f5) {
  949. // Color the label and help text
  950. .help-block,
  951. .control-label,
  952. .radio,
  953. .checkbox,
  954. .radio-inline,
  955. .checkbox-inline {
  956. color: @text-color;
  957. }
  958. // Set the border and box shadow on specific inputs to match
  959. .form-control {
  960. border-color: @border-color;
  961. .box-shadow(
  962. inset 0 1px 1px rgba(0, 0, 0, 0.075)
  963. ); // Redeclare so transitions work
  964. &:focus {
  965. border-color: darken(@border-color, 10%);
  966. @shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),
  967. 0 0 6px lighten(@border-color, 20%);
  968. .box-shadow(@shadow);
  969. }
  970. }
  971. // Set validation states also for addons
  972. .input-group-addon {
  973. color: @text-color;
  974. border-color: @border-color;
  975. background-color: @background-color;
  976. }
  977. // Optional feedback icon
  978. .form-control-feedback {
  979. color: @text-color;
  980. }
  981. }
  982. // Form control focus state
  983. //
  984. // Generate a customized focus state and for any input with the specified color,
  985. // which defaults to the `@input-focus-border` variable.
  986. //
  987. // We highly encourage you to not customize the default value, but instead use
  988. // this to tweak colors on an as-needed basis. This aesthetic change is based on
  989. // WebKit's default styles, but applicable to a wider range of browsers. Its
  990. // usability and accessibility should be taken into account with any change.
  991. //
  992. // Example usage: change the default blue border and shadow to white for better
  993. // contrast against a dark gray background.
  994. .form-control-focus(@color: @input-border-focus) {
  995. @color-rgba: rgba(red(@color), green(@color), blue(@color), 0.6);
  996. &:focus {
  997. border-color: @color;
  998. outline: 0;
  999. .box-shadow(~'inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px @{color-rgba}');
  1000. }
  1001. }
  1002. // Form control sizing
  1003. //
  1004. // Relative text size, padding, and border-radii changes for form controls. For
  1005. // horizontal sizing, wrap controls in the predefined grid classes. `<select>`
  1006. // element gets special love because it's special, and that's a fact!
  1007. .input-size(@input-height; @padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) {
  1008. height: @input-height;
  1009. padding: @padding-vertical @padding-horizontal;
  1010. font-size: @font-size;
  1011. line-height: @line-height;
  1012. border-radius: @border-radius;
  1013. select& {
  1014. height: @input-height;
  1015. line-height: @input-height;
  1016. }
  1017. textarea&,
  1018. select[multiple]& {
  1019. height: auto;
  1020. }
  1021. }
  1022. .triangle(@_, @width, @height, @color) {
  1023. position: absolute;
  1024. border-color: transparent;
  1025. border-style: solid;
  1026. width: 0;
  1027. height: 0;
  1028. }
  1029. .triangle(top, @width, @height, @color) {
  1030. border-width: 0 @width / 2 @height @width / 2;
  1031. border-bottom-color: @color;
  1032. border-left-color: transparent;
  1033. border-right-color: transparent;
  1034. }
  1035. .triangle(bottom, @width, @height, @color) {
  1036. border-width: @height @width / 2 0 @width / 2;
  1037. border-top-color: @color;
  1038. border-left-color: transparent;
  1039. border-right-color: transparent;
  1040. }
  1041. .triangle(right, @width, @height, @color) {
  1042. border-width: @height / 2 0 @height / 2 @width;
  1043. border-left-color: @color;
  1044. border-top-color: transparent;
  1045. border-bottom-color: transparent;
  1046. }
  1047. .triangle(left, @width, @height, @color) {
  1048. border-width: @height / 2 @width @height / 2 0;
  1049. border-right-color: @color;
  1050. border-top-color: transparent;
  1051. border-bottom-color: transparent;
  1052. }
  1053. .no-outline-ring-on-click {
  1054. &:focus,
  1055. &:focus:active {
  1056. outline: 0;
  1057. }
  1058. }