mixins.less 32 KB

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