_mixins.scss 27 KB

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