mixins.less 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. //
  2. // Mixins
  3. // --------------------------------------------------
  4. // UTILITY MIXINS
  5. // --------------------------------------------------
  6. // Clearfix
  7. // --------
  8. // For clearing floats like a boss h5bp.com/q
  9. .clearfix {
  10. *zoom: 1;
  11. &:before,
  12. &:after {
  13. display: table;
  14. content: "";
  15. // Fixes Opera/contenteditable bug:
  16. // http://nicolasgallagher.com/micro-clearfix-hack/#comment-36952
  17. line-height: 0;
  18. }
  19. &:after {
  20. clear: both;
  21. }
  22. }
  23. // Webkit-style focus
  24. // ------------------
  25. .tab-focus() {
  26. // Default
  27. outline: thin dotted #333;
  28. // Webkit
  29. outline: 5px auto -webkit-focus-ring-color;
  30. outline-offset: -2px;
  31. }
  32. // Center-align a block level element
  33. // ----------------------------------
  34. .center-block() {
  35. display: block;
  36. margin-left: auto;
  37. margin-right: auto;
  38. }
  39. // IE7 inline-block
  40. // ----------------
  41. .ie7-inline-block() {
  42. *display: inline; /* IE7 inline-block hack */
  43. *zoom: 1;
  44. }
  45. // IE7 likes to collapse whitespace on either side of the inline-block elements.
  46. // Ems because we're attempting to match the width of a space character. Left
  47. // version is for form buttons, which typically come after other elements, and
  48. // right version is for icons, which come before. Applying both is ok, but it will
  49. // mean that space between those elements will be .6em (~2 space characters) in IE7,
  50. // instead of the 1 space in other browsers.
  51. .ie7-restore-left-whitespace() {
  52. *margin-left: .3em;
  53. &:first-child {
  54. *margin-left: 0;
  55. }
  56. }
  57. .ie7-restore-right-whitespace() {
  58. *margin-right: .3em;
  59. }
  60. // Sizing shortcuts
  61. // -------------------------
  62. .size(@height, @width) {
  63. width: @width;
  64. height: @height;
  65. }
  66. .square(@size) {
  67. .size(@size, @size);
  68. }
  69. // Placeholder text
  70. // -------------------------
  71. .placeholder(@color: @placeholderText) {
  72. &:-moz-placeholder {
  73. color: @color;
  74. }
  75. &:-ms-input-placeholder {
  76. color: @color;
  77. }
  78. &::-webkit-input-placeholder {
  79. color: @color;
  80. }
  81. }
  82. // Text overflow
  83. // -------------------------
  84. // Requires inline-block or block for proper styling
  85. .text-overflow() {
  86. overflow: hidden;
  87. text-overflow: ellipsis;
  88. white-space: nowrap;
  89. }
  90. // CSS image replacement
  91. // -------------------------
  92. // Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757
  93. .hide-text {
  94. font: 0/0 a;
  95. color: transparent;
  96. text-shadow: none;
  97. background-color: transparent;
  98. border: 0;
  99. }
  100. // FONTS
  101. // --------------------------------------------------
  102. #font {
  103. #family {
  104. .serif() {
  105. font-family: @serifFontFamily;
  106. }
  107. .sans-serif() {
  108. font-family: @sansFontFamily;
  109. }
  110. .monospace() {
  111. font-family: @monoFontFamily;
  112. }
  113. }
  114. .shorthand(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
  115. font-size: @size;
  116. font-weight: @weight;
  117. line-height: @lineHeight;
  118. }
  119. .serif(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
  120. #font > #family > .serif;
  121. #font > .shorthand(@size, @weight, @lineHeight);
  122. }
  123. .sans-serif(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
  124. #font > #family > .sans-serif;
  125. #font > .shorthand(@size, @weight, @lineHeight);
  126. }
  127. .monospace(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
  128. #font > #family > .monospace;
  129. #font > .shorthand(@size, @weight, @lineHeight);
  130. }
  131. }
  132. // FORMS
  133. // --------------------------------------------------
  134. // Block level inputs
  135. .input-block-level {
  136. display: block;
  137. width: 100%;
  138. min-height: 30px; // Make inputs at least the height of their button counterpart
  139. .box-sizing(border-box); // Makes inputs behave like true block-level elements
  140. }
  141. // Mixin for form field states
  142. .formFieldState(@textColor: #555, @borderColor: #ccc, @backgroundColor: #f5f5f5) {
  143. // Set the text color
  144. > label,
  145. .help-block,
  146. .help-inline {
  147. color: @textColor;
  148. }
  149. // Style inputs accordingly
  150. .checkbox,
  151. .radio,
  152. input,
  153. select,
  154. textarea {
  155. color: @textColor;
  156. }
  157. input,
  158. select,
  159. textarea {
  160. border-color: @borderColor;
  161. .box-shadow(inset 0 1px 1px rgba(0,0,0,.075)); // Redeclare so transitions work
  162. &:focus {
  163. border-color: darken(@borderColor, 10%);
  164. .box-shadow(inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px lighten(@borderColor, 20%));
  165. }
  166. }
  167. // Give a small background color for input-prepend/-append
  168. .input-prepend .add-on,
  169. .input-append .add-on {
  170. color: @textColor;
  171. background-color: @backgroundColor;
  172. border-color: @textColor;
  173. }
  174. }
  175. // CSS3 PROPERTIES
  176. // --------------------------------------------------
  177. // Border Radius
  178. .border-radius(@radius) {
  179. -webkit-border-radius: @radius;
  180. -moz-border-radius: @radius;
  181. border-radius: @radius;
  182. }
  183. // Single Corner Border Radius
  184. .border-top-left-radius(@radius) {
  185. -webkit-border-top-left-radius: @radius;
  186. -moz-border-radius-topleft: @radius;
  187. border-top-left-radius: @radius;
  188. }
  189. .border-top-right-radius(@radius) {
  190. -webkit-border-top-right-radius: @radius;
  191. -moz-border-radius-topright: @radius;
  192. border-top-right-radius: @radius;
  193. }
  194. .border-bottom-right-radius(@radius) {
  195. -webkit-border-bottom-right-radius: @radius;
  196. -moz-border-radius-bottomright: @radius;
  197. border-bottom-right-radius: @radius;
  198. }
  199. .border-bottom-left-radius(@radius) {
  200. -webkit-border-bottom-left-radius: @radius;
  201. -moz-border-radius-bottomleft: @radius;
  202. border-bottom-left-radius: @radius;
  203. }
  204. // Single Side Border Radius
  205. .border-top-radius(@radius) {
  206. .border-top-right-radius(@radius);
  207. .border-top-left-radius(@radius);
  208. }
  209. .border-right-radius(@radius) {
  210. .border-top-right-radius(@radius);
  211. .border-bottom-right-radius(@radius);
  212. }
  213. .border-bottom-radius(@radius) {
  214. .border-bottom-right-radius(@radius);
  215. .border-bottom-left-radius(@radius);
  216. }
  217. .border-left-radius(@radius) {
  218. .border-top-left-radius(@radius);
  219. .border-bottom-left-radius(@radius);
  220. }
  221. // Drop shadows
  222. .box-shadow(@shadowA, @shadowB:X, ...){
  223. // Multiple shadow solution from http://toekneestuck.com/blog/2012/05/15/less-css-arguments-variable/
  224. @props: ~`"@{arguments}".replace(/[\[\]]|\,\sX/g, '')`;
  225. -webkit-box-shadow: @props;
  226. -moz-box-shadow: @props;
  227. box-shadow: @props;
  228. }
  229. // Transitions
  230. .transition(@transition) {
  231. -webkit-transition: @transition;
  232. -moz-transition: @transition;
  233. -o-transition: @transition;
  234. transition: @transition;
  235. }
  236. .transition-delay(@transition-delay) {
  237. -webkit-transition-delay: @transition-delay;
  238. -moz-transition-delay: @transition-delay;
  239. -o-transition-delay: @transition-delay;
  240. transition-delay: @transition-delay;
  241. }
  242. // Transformations
  243. .rotate(@degrees) {
  244. -webkit-transform: rotate(@degrees);
  245. -moz-transform: rotate(@degrees);
  246. -ms-transform: rotate(@degrees);
  247. -o-transform: rotate(@degrees);
  248. transform: rotate(@degrees);
  249. }
  250. .scale(@ratio) {
  251. -webkit-transform: scale(@ratio);
  252. -moz-transform: scale(@ratio);
  253. -ms-transform: scale(@ratio);
  254. -o-transform: scale(@ratio);
  255. transform: scale(@ratio);
  256. }
  257. .translate(@x, @y) {
  258. -webkit-transform: translate(@x, @y);
  259. -moz-transform: translate(@x, @y);
  260. -ms-transform: translate(@x, @y);
  261. -o-transform: translate(@x, @y);
  262. transform: translate(@x, @y);
  263. }
  264. .skew(@x, @y) {
  265. -webkit-transform: skew(@x, @y);
  266. -moz-transform: skew(@x, @y);
  267. -ms-transform: skewX(@x) skewY(@y); // See https://github.com/twitter/bootstrap/issues/4885
  268. -o-transform: skew(@x, @y);
  269. transform: skew(@x, @y);
  270. }
  271. .translate3d(@x, @y, @z) {
  272. -webkit-transform: translate3d(@x, @y, @z);
  273. -moz-transform: translate3d(@x, @y, @z);
  274. -o-transform: translate3d(@x, @y, @z);
  275. transform: translate3d(@x, @y, @z);
  276. }
  277. // Backface visibility
  278. // Prevent browsers from flickering when using CSS 3D transforms.
  279. // Default value is `visible`, but can be changed to `hidden
  280. // See git pull https://github.com/dannykeane/bootstrap.git backface-visibility for examples
  281. .backface-visibility(@visibility){
  282. -webkit-backface-visibility: @visibility;
  283. -moz-backface-visibility: @visibility;
  284. backface-visibility: @visibility;
  285. }
  286. // Background clipping
  287. // Heads up: FF 3.6 and under need "padding" instead of "padding-box"
  288. .background-clip(@clip) {
  289. -webkit-background-clip: @clip;
  290. -moz-background-clip: @clip;
  291. background-clip: @clip;
  292. }
  293. // Background sizing
  294. .background-size(@size){
  295. -webkit-background-size: @size;
  296. -moz-background-size: @size;
  297. -o-background-size: @size;
  298. background-size: @size;
  299. }
  300. // Box sizing
  301. .box-sizing(@boxmodel) {
  302. -webkit-box-sizing: @boxmodel;
  303. -moz-box-sizing: @boxmodel;
  304. box-sizing: @boxmodel;
  305. }
  306. // User select
  307. // For selecting text on the page
  308. .user-select(@select) {
  309. -webkit-user-select: @select;
  310. -moz-user-select: @select;
  311. -ms-user-select: @select;
  312. -o-user-select: @select;
  313. user-select: @select;
  314. }
  315. // Resize anything
  316. .resizable(@direction) {
  317. resize: @direction; // Options: horizontal, vertical, both
  318. overflow: auto; // Safari fix
  319. }
  320. // CSS3 Content Columns
  321. .content-columns(@columnCount, @columnGap: @gridGutterWidth) {
  322. -webkit-column-count: @columnCount;
  323. -moz-column-count: @columnCount;
  324. column-count: @columnCount;
  325. -webkit-column-gap: @columnGap;
  326. -moz-column-gap: @columnGap;
  327. column-gap: @columnGap;
  328. }
  329. // Optional hyphenation
  330. .hyphens(@mode: auto) {
  331. word-wrap: break-word;
  332. -webkit-hyphens: @mode;
  333. -moz-hyphens: @mode;
  334. -ms-hyphens: @mode;
  335. -o-hyphens: @mode;
  336. hyphens: @mode;
  337. }
  338. // Opacity
  339. .opacity(@opacity) {
  340. opacity: @opacity / 100;
  341. filter: ~"alpha(opacity=@{opacity})";
  342. }
  343. // BACKGROUNDS
  344. // --------------------------------------------------
  345. // Add an alphatransparency value to any background or border color (via Elyse Holladay)
  346. #translucent {
  347. .background(@color: @white, @alpha: 1) {
  348. background-color: hsla(hue(@color), saturation(@color), lightness(@color), @alpha);
  349. }
  350. .border(@color: @white, @alpha: 1) {
  351. border-color: hsla(hue(@color), saturation(@color), lightness(@color), @alpha);
  352. .background-clip(padding-box);
  353. }
  354. }
  355. // Gradient Bar Colors for buttons and alerts
  356. .gradientBar(@primaryColor, @secondaryColor, @textColor: #fff, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) {
  357. color: @textColor;
  358. text-shadow: @textShadow;
  359. #gradient > .vertical(@primaryColor, @secondaryColor);
  360. border-color: @secondaryColor @secondaryColor darken(@secondaryColor, 15%);
  361. border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) fadein(rgba(0,0,0,.1), 15%);
  362. }
  363. // Gradients
  364. #gradient {
  365. .horizontal(@startColor: #555, @endColor: #333) {
  366. background-color: @endColor;
  367. background-image: -moz-linear-gradient(left, @startColor, @endColor); // FF 3.6+
  368. background-image: -webkit-gradient(linear, 0 0, 100% 0, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+
  369. background-image: -webkit-linear-gradient(left, @startColor, @endColor); // Safari 5.1+, Chrome 10+
  370. background-image: -o-linear-gradient(left, @startColor, @endColor); // Opera 11.10
  371. background-image: linear-gradient(to right, @startColor, @endColor); // Standard, IE10
  372. background-repeat: repeat-x;
  373. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(@startColor),argb(@endColor))); // IE9 and down
  374. }
  375. .vertical(@startColor: #555, @endColor: #333) {
  376. background-color: mix(@startColor, @endColor, 60%);
  377. background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+
  378. background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+
  379. background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+
  380. background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10
  381. background-image: linear-gradient(to bottom, @startColor, @endColor); // Standard, IE10
  382. background-repeat: repeat-x;
  383. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor),argb(@endColor))); // IE9 and down
  384. }
  385. .directional(@startColor: #555, @endColor: #333, @deg: 45deg) {
  386. background-color: @endColor;
  387. background-repeat: repeat-x;
  388. background-image: -moz-linear-gradient(@deg, @startColor, @endColor); // FF 3.6+
  389. background-image: -webkit-linear-gradient(@deg, @startColor, @endColor); // Safari 5.1+, Chrome 10+
  390. background-image: -o-linear-gradient(@deg, @startColor, @endColor); // Opera 11.10
  391. background-image: linear-gradient(@deg, @startColor, @endColor); // Standard, IE10
  392. }
  393. .vertical-three-colors(@startColor: #00b3ee, @midColor: #7a43b6, @colorStop: 50%, @endColor: #c3325f) {
  394. background-color: mix(@midColor, @endColor, 80%);
  395. background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), color-stop(@colorStop, @midColor), to(@endColor));
  396. background-image: -webkit-linear-gradient(@startColor, @midColor @colorStop, @endColor);
  397. background-image: -moz-linear-gradient(top, @startColor, @midColor @colorStop, @endColor);
  398. background-image: -o-linear-gradient(@startColor, @midColor @colorStop, @endColor);
  399. background-image: linear-gradient(@startColor, @midColor @colorStop, @endColor);
  400. background-repeat: no-repeat;
  401. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor),argb(@endColor))); // IE9 and down, gets no color-stop at all for proper fallback
  402. }
  403. .radial(@innerColor: #555, @outerColor: #333) {
  404. background-color: @outerColor;
  405. background-image: -webkit-gradient(radial, center center, 0, center center, 460, from(@innerColor), to(@outerColor));
  406. background-image: -webkit-radial-gradient(circle, @innerColor, @outerColor);
  407. background-image: -moz-radial-gradient(circle, @innerColor, @outerColor);
  408. background-image: -o-radial-gradient(circle, @innerColor, @outerColor);
  409. background-repeat: no-repeat;
  410. }
  411. .striped(@color: #555, @angle: 45deg) {
  412. background-color: @color;
  413. background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, rgba(255,255,255,.15)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255,255,255,.15)), color-stop(.75, rgba(255,255,255,.15)), color-stop(.75, transparent), to(transparent));
  414. background-image: -webkit-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
  415. background-image: -moz-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
  416. background-image: -o-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
  417. background-image: linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
  418. }
  419. }
  420. // Reset filters for IE
  421. .reset-filter() {
  422. filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)"));
  423. }
  424. // COMPONENT MIXINS
  425. // --------------------------------------------------
  426. // Horizontal dividers
  427. // -------------------------
  428. // Dividers (basically an hr) within dropdowns and nav lists
  429. .nav-divider(@top: #e5e5e5, @bottom: @white) {
  430. // IE7 needs a set width since we gave a height. Restricting just
  431. // to IE7 to keep the 1px left/right space in other browsers.
  432. // It is unclear where IE is getting the extra space that we need
  433. // to negative-margin away, but so it goes.
  434. *width: 100%;
  435. height: 1px;
  436. margin: ((@baseLineHeight / 2) - 1) 1px; // 8px 1px
  437. *margin: -5px 0 5px;
  438. overflow: hidden;
  439. background-color: @top;
  440. border-bottom: 1px solid @bottom;
  441. }
  442. // Button backgrounds
  443. // ------------------
  444. .buttonBackground(@startColor, @endColor, @textColor: #fff, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) {
  445. // gradientBar will set the background to a pleasing blend of these, to support IE<=9
  446. .gradientBar(@startColor, @endColor, @textColor, @textShadow);
  447. *background-color: @endColor; /* Darken IE7 buttons by default so they stand out more given they won't have borders */
  448. .reset-filter();
  449. // in these cases the gradient won't cover the background, so we override
  450. &:hover, &:active, &.active, &.disabled, &[disabled] {
  451. color: @textColor;
  452. background-color: @endColor;
  453. *background-color: darken(@endColor, 5%);
  454. }
  455. // IE 7 + 8 can't handle box-shadow to show active, so we darken a bit ourselves
  456. &:active,
  457. &.active {
  458. background-color: darken(@endColor, 10%) e("\9");
  459. }
  460. }
  461. // Navbar vertical align
  462. // -------------------------
  463. // Vertically center elements in the navbar.
  464. // Example: an element has a height of 30px, so write out `.navbarVerticalAlign(30px);` to calculate the appropriate top margin.
  465. .navbarVerticalAlign(@elementHeight) {
  466. margin-top: (@navbarHeight - @elementHeight) / 2;
  467. }
  468. // Grid System
  469. // -----------
  470. // Centered container element
  471. .container-fixed() {
  472. margin-right: auto;
  473. margin-left: auto;
  474. .clearfix();
  475. }
  476. // Table columns
  477. .tableColumns(@columnSpan: 1) {
  478. float: none; // undo default grid column styles
  479. width: ((@gridColumnWidth) * @columnSpan) + (@gridGutterWidth * (@columnSpan - 1)) - 16; // 16 is total padding on left and right of table cells
  480. margin-left: 0; // undo default grid column styles
  481. }
  482. // Make a Grid
  483. // Use .makeRow and .makeColumn to assign semantic layouts grid system behavior
  484. .makeRow() {
  485. margin-left: @gridGutterWidth * -1;
  486. .clearfix();
  487. }
  488. .makeColumn(@columns: 1, @offset: 0) {
  489. float: left;
  490. margin-left: (@gridColumnWidth * @offset) + (@gridGutterWidth * (@offset - 1)) + (@gridGutterWidth * 2);
  491. width: (@gridColumnWidth * @columns) + (@gridGutterWidth * (@columns - 1));
  492. }
  493. // The Grid
  494. #grid {
  495. .core (@gridColumnWidth, @gridGutterWidth) {
  496. .spanX (@index) when (@index > 0) {
  497. (~".span@{index}") { .span(@index); }
  498. .spanX(@index - 1);
  499. }
  500. .spanX (0) {}
  501. .offsetX (@index) when (@index > 0) {
  502. (~".offset@{index}") { .offset(@index); }
  503. .offsetX(@index - 1);
  504. }
  505. .offsetX (0) {}
  506. .offset (@columns) {
  507. margin-left: (@gridColumnWidth * @columns) + (@gridGutterWidth * (@columns + 1));
  508. }
  509. .span (@columns) {
  510. width: (@gridColumnWidth * @columns) + (@gridGutterWidth * (@columns - 1));
  511. }
  512. .row {
  513. margin-left: @gridGutterWidth * -1;
  514. .clearfix();
  515. }
  516. [class*="span"] {
  517. float: left;
  518. min-height: 1px; // prevent collapsing columns
  519. margin-left: @gridGutterWidth;
  520. }
  521. // Set the container width, and override it for fixed navbars in media queries
  522. .container,
  523. .navbar-static-top .container,
  524. .navbar-fixed-top .container,
  525. .navbar-fixed-bottom .container { .span(@gridColumns); }
  526. // generate .spanX and .offsetX
  527. .spanX (@gridColumns);
  528. .offsetX (@gridColumns);
  529. }
  530. .fluid (@fluidGridColumnWidth, @fluidGridGutterWidth) {
  531. .spanX (@index) when (@index > 0) {
  532. (~".span@{index}") { .span(@index); }
  533. .spanX(@index - 1);
  534. }
  535. .spanX (0) {}
  536. .offsetX (@index) when (@index > 0) {
  537. (~'.offset@{index}') { .offset(@index); }
  538. (~'.offset@{index}:first-child') { .offsetFirstChild(@index); }
  539. .offsetX(@index - 1);
  540. }
  541. .offsetX (0) {}
  542. .offset (@columns) {
  543. margin-left: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1)) + (@fluidGridGutterWidth*2);
  544. *margin-left: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1)) - (.5 / @gridRowWidth * 100 * 1%) + (@fluidGridGutterWidth*2) - (.5 / @gridRowWidth * 100 * 1%);
  545. }
  546. .offsetFirstChild (@columns) {
  547. margin-left: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1)) + (@fluidGridGutterWidth);
  548. *margin-left: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1)) - (.5 / @gridRowWidth * 100 * 1%) + @fluidGridGutterWidth - (.5 / @gridRowWidth * 100 * 1%);
  549. }
  550. .span (@columns) {
  551. width: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1));
  552. *width: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1)) - (.5 / @gridRowWidth * 100 * 1%);
  553. }
  554. .row-fluid {
  555. width: 100%;
  556. .clearfix();
  557. [class*="span"] {
  558. .input-block-level();
  559. float: left;
  560. margin-left: @fluidGridGutterWidth;
  561. *margin-left: @fluidGridGutterWidth - (.5 / @gridRowWidth * 100 * 1%);
  562. }
  563. [class*="span"]:first-child {
  564. margin-left: 0;
  565. }
  566. // generate .spanX and .offsetX
  567. .spanX (@gridColumns);
  568. .offsetX (@gridColumns);
  569. }
  570. }
  571. .input(@gridColumnWidth, @gridGutterWidth) {
  572. .spanX (@index) when (@index > 0) {
  573. (~"input.span@{index}, textarea.span@{index}, .uneditable-input.span@{index}") { .span(@index); }
  574. .spanX(@index - 1);
  575. }
  576. .spanX (0) {}
  577. .span(@columns) {
  578. width: ((@gridColumnWidth) * @columns) + (@gridGutterWidth * (@columns - 1)) - 14;
  579. }
  580. input,
  581. textarea,
  582. .uneditable-input {
  583. margin-left: 0; // override margin-left from core grid system
  584. }
  585. // Space grid-sized controls properly if multiple per line
  586. .controls-row [class*="span"] + [class*="span"] {
  587. margin-left: @gridGutterWidth;
  588. }
  589. // generate .spanX
  590. .spanX (@gridColumns);
  591. }
  592. }