mixins.less 32 KB

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