mixins.less 28 KB

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