aboutsummaryrefslogtreecommitdiff
path: root/less/mixins.less
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2013-12-14 15:38:21 -0800
committerMark Otto <[email protected]>2013-12-14 15:38:21 -0800
commita54dbfdf2a08ff04fc65f8e4f77ee5dc76bf4ef3 (patch)
tree9b1c5697a731543a86711b016e1986ec1e81dad4 /less/mixins.less
parent80e86442308b2cc86ba948de87e854057933e3ab (diff)
parentf1869771bc8b8e8a6c7a98385ec58e0bf0d2d98e (diff)
downloadbootstrap-a54dbfdf2a08ff04fc65f8e4f77ee5dc76bf4ef3.tar.xz
bootstrap-a54dbfdf2a08ff04fc65f8e4f77ee5dc76bf4ef3.zip
Merge branch 'master' into pr/10951
Conflicts: dist/css/bootstrap.min.css less/modals.less
Diffstat (limited to 'less/mixins.less')
-rw-r--r--less/mixins.less203
1 files changed, 153 insertions, 50 deletions
diff --git a/less/mixins.less b/less/mixins.less
index 6e0e399af..dbe9ed4a7 100644
--- a/less/mixins.less
+++ b/less/mixins.less
@@ -19,19 +19,19 @@
.clearfix() {
&:before,
&:after {
- content: " "; /* 1 */
- display: table; /* 2 */
+ content: " "; // 1
+ display: table; // 2
}
&:after {
clear: both;
}
}
-// Webkit-style focus
+// WebKit-style focus
.tab-focus() {
// Default
- outline: thin dotted #333;
- // Webkit
+ outline: thin dotted;
+ // WebKit
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
@@ -55,7 +55,8 @@
// Placeholder text
.placeholder(@color: @input-color-placeholder) {
&:-moz-placeholder { color: @color; } // Firefox 4-18
- &::-moz-placeholder { color: @color; } // Firefox 19+
+ &::-moz-placeholder { color: @color; // Firefox 19+
+ opacity: 1; } // See https://github.com/twbs/bootstrap/pull/11526
&:-ms-input-placeholder { color: @color; } // Internet Explorer 10+
&::-webkit-input-placeholder { color: @color; } // Safari and Chrome
}
@@ -87,11 +88,7 @@
}
// New mixin to use as of v3.0.1
.text-hide() {
- font: ~"0/0" a;
- color: transparent;
- text-shadow: none;
- background-color: transparent;
- border: 0;
+ .hide-text();
}
@@ -150,17 +147,17 @@
// Transformations
.rotate(@degrees) {
-webkit-transform: rotate(@degrees);
- -ms-transform: rotate(@degrees); // IE9+
+ -ms-transform: rotate(@degrees); // IE9 only
transform: rotate(@degrees);
}
-.scale(@ratio) {
- -webkit-transform: scale(@ratio);
- -ms-transform: scale(@ratio); // IE9+
- transform: scale(@ratio);
+.scale(@ratio; @ratio-y...) {
+ -webkit-transform: scale(@ratio, @ratio-y);
+ -ms-transform: scale(@ratio, @ratio-y); // IE9 only
+ transform: scale(@ratio, @ratio-y);
}
.translate(@x; @y) {
-webkit-transform: translate(@x, @y);
- -ms-transform: translate(@x, @y); // IE9+
+ -ms-transform: translate(@x, @y); // IE9 only
transform: translate(@x, @y);
}
.skew(@x; @y) {
@@ -175,12 +172,12 @@
.rotateX(@degrees) {
-webkit-transform: rotateX(@degrees);
- -ms-transform: rotateX(@degrees); // IE9+
+ -ms-transform: rotateX(@degrees); // IE9 only
transform: rotateX(@degrees);
}
.rotateY(@degrees) {
-webkit-transform: rotateY(@degrees);
- -ms-transform: rotateY(@degrees); // IE9+
+ -ms-transform: rotateY(@degrees); // IE9 only
transform: rotateY(@degrees);
}
.perspective(@perspective) {
@@ -193,17 +190,22 @@
-moz-perspective-origin: @perspective;
perspective-origin: @perspective;
}
-.transform-origin(@origin){
+.transform-origin(@origin) {
-webkit-transform-origin: @origin;
-moz-transform-origin: @origin;
+ -ms-transform-origin: @origin; // IE9 only
transform-origin: @origin;
}
+// Animations
+.animation(@animation) {
+ -webkit-animation: @animation;
+ animation: @animation;
+}
// Backface visibility
// Prevent browsers from flickering when using CSS 3D transforms.
// Default value is `visible`, but can be changed to `hidden`
-// See git pull https://github.com/dannykeane/bootstrap.git backface-visibility for examples
.backface-visibility(@visibility){
-webkit-backface-visibility: @visibility;
-moz-backface-visibility: @visibility;
@@ -273,10 +275,8 @@
// Creates two color stops, start and end, by specifying a color and position for each color stop.
// Color stops are not available in IE9 and below.
.horizontal(@start-color: #555; @end-color: #333; @start-percent: 0%; @end-percent: 100%) {
- background-image: -webkit-gradient(linear, @start-percent top, @end-percent top, from(@start-color), to(@end-color)); // Safari 4+, Chrome 2+
- background-image: -webkit-linear-gradient(left, color-stop(@start-color @start-percent), color-stop(@end-color @end-percent)); // Safari 5.1+, Chrome 10+
- background-image: -moz-linear-gradient(left, @start-color @start-percent, @end-color @end-percent); // FF 3.6+
- background-image: linear-gradient(to right, @start-color @start-percent, @end-color @end-percent); // Standard, IE10
+ background-image: -webkit-linear-gradient(left, color-stop(@start-color @start-percent), color-stop(@end-color @end-percent)); // Safari 5.1-6, Chrome 10+
+ 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+
background-repeat: repeat-x;
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(@start-color),argb(@end-color))); // IE9 and down
}
@@ -286,47 +286,36 @@
// Creates two color stops, start and end, by specifying a color and position for each color stop.
// Color stops are not available in IE9 and below.
.vertical(@start-color: #555; @end-color: #333; @start-percent: 0%; @end-percent: 100%) {
- background-image: -webkit-gradient(linear, left @start-percent, left @end-percent, from(@start-color), to(@end-color)); // Safari 4+, Chrome 2+
- background-image: -webkit-linear-gradient(top, @start-color, @start-percent, @end-color, @end-percent); // Safari 5.1+, Chrome 10+
- background-image: -moz-linear-gradient(top, @start-color @start-percent, @end-color @end-percent); // FF 3.6+
- background-image: linear-gradient(to bottom, @start-color @start-percent, @end-color @end-percent); // Standard, IE10
+ background-image: -webkit-linear-gradient(top, @start-color @start-percent, @end-color @end-percent); // Safari 5.1-6, Chrome 10+
+ 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+
background-repeat: repeat-x;
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@start-color),argb(@end-color))); // IE9 and down
}
.directional(@start-color: #555; @end-color: #333; @deg: 45deg) {
background-repeat: repeat-x;
- background-image: -webkit-linear-gradient(@deg, @start-color, @end-color); // Safari 5.1+, Chrome 10+
- background-image: -moz-linear-gradient(@deg, @start-color, @end-color); // FF 3.6+
- background-image: linear-gradient(@deg, @start-color, @end-color); // Standard, IE10
+ background-image: -webkit-linear-gradient(@deg, @start-color, @end-color); // Safari 5.1-6, Chrome 10+
+ background-image: linear-gradient(@deg, @start-color, @end-color); // Standard, IE10, Firefox 16+, Opera 12.10+, Safari 7+, Chrome 26+
}
.horizontal-three-colors(@start-color: #00b3ee; @mid-color: #7a43b6; @color-stop: 50%; @end-color: #c3325f) {
- background-image: -webkit-gradient(left, linear, 0 0, 0 100%, from(@start-color), color-stop(@color-stop, @mid-color), to(@end-color));
background-image: -webkit-linear-gradient(left, @start-color, @mid-color @color-stop, @end-color);
- background-image: -moz-linear-gradient(left, @start-color, @mid-color @color-stop, @end-color);
background-image: linear-gradient(to right, @start-color, @mid-color @color-stop, @end-color);
background-repeat: no-repeat;
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(@start-color),argb(@end-color))); // IE9 and down, gets no color-stop at all for proper fallback
}
.vertical-three-colors(@start-color: #00b3ee; @mid-color: #7a43b6; @color-stop: 50%; @end-color: #c3325f) {
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@start-color), color-stop(@color-stop, @mid-color), to(@end-color));
background-image: -webkit-linear-gradient(@start-color, @mid-color @color-stop, @end-color);
- background-image: -moz-linear-gradient(top, @start-color, @mid-color @color-stop, @end-color);
background-image: linear-gradient(@start-color, @mid-color @color-stop, @end-color);
background-repeat: no-repeat;
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@start-color),argb(@end-color))); // IE9 and down, gets no color-stop at all for proper fallback
}
.radial(@inner-color: #555; @outer-color: #333) {
- background-image: -webkit-gradient(radial, center center, 0, center center, 460, from(@inner-color), to(@outer-color));
background-image: -webkit-radial-gradient(circle, @inner-color, @outer-color);
- background-image: -moz-radial-gradient(circle, @inner-color, @outer-color);
background-image: radial-gradient(circle, @inner-color, @outer-color);
background-repeat: no-repeat;
}
.striped(@color: rgba(255,255,255,.15); @angle: 45deg) {
- background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, @color), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, @color), color-stop(.75, @color), color-stop(.75, transparent), to(transparent));
background-image: -webkit-linear-gradient(@angle, @color 25%, transparent 25%, transparent 50%, @color 50%, @color 75%, transparent 75%, transparent);
- background-image: -moz-linear-gradient(@angle, @color 25%, transparent 25%, transparent 50%, @color 50%, @color 75%, transparent 75%, transparent);
background-image: linear-gradient(@angle, @color 25%, transparent 25%, transparent 50%, @color 50%, @color 75%, transparent 75%, transparent);
}
}
@@ -365,7 +354,7 @@
//
// Keep images from scaling beyond the width of their parents.
-.img-responsive(@display: block;) {
+.img-responsive(@display: block) {
display: @display;
max-width: 100%; // Part 1: Set a maximum relative to the parent
height: auto; // Part 2: Scale the height according to the width, otherwise you get stretching
@@ -387,12 +376,14 @@
// Panels
// -------------------------
-.panel-variant(@border; @heading-text-color; @heading-bg-color; @heading-border;) {
+.panel-variant(@border; @heading-text-color; @heading-bg-color; @heading-border) {
border-color: @border;
+
& > .panel-heading {
color: @heading-text-color;
background-color: @heading-bg-color;
border-color: @heading-border;
+
+ .panel-collapse .panel-body {
border-top-color: @border;
}
@@ -410,6 +401,7 @@
background-color: @background;
border-color: @border;
color: @text-color;
+
hr {
border-top-color: darken(@border, 5%);
}
@@ -420,7 +412,7 @@
// Tables
// -------------------------
-.table-row-variant(@state; @background; @border) {
+.table-row-variant(@state; @background) {
// Exact selectors below required to override `.table-striped` and prevent
// inheritance to nested tables.
.table > thead > tr,
@@ -431,7 +423,6 @@
&.@{state} > td,
&.@{state} > th {
background-color: @background;
- border-color: @border;
}
}
@@ -443,7 +434,34 @@
&.@{state}:hover > td,
&.@{state}:hover > th {
background-color: darken(@background, 5%);
- border-color: darken(@border, 5%);
+ }
+ }
+}
+
+// List Groups
+// -------------------------
+.list-group-item-variant(@state; @background; @color) {
+ .list-group-item-@{state} {
+ color: @color;
+ background-color: @background;
+
+ a& {
+ color: @color;
+
+ .list-group-item-heading { color: inherit; }
+
+ &:hover,
+ &:focus {
+ color: @color;
+ background-color: darken(@background, 5%);
+ }
+ &.active,
+ &.active:hover,
+ &.active:focus {
+ color: #fff;
+ background-color: @color;
+ border-color: @color;
+ }
}
}
}
@@ -483,6 +501,11 @@
border-color: @border;
}
}
+
+ .badge {
+ color: @background;
+ background-color: @color;
+ }
}
// Button sizes
@@ -553,9 +576,10 @@
// More easily include all the states for responsive-utilities.less.
.responsive-visibility() {
display: block !important;
- tr& { display: table-row !important; }
+ table& { display: table; }
+ tr& { display: table-row !important; }
th&,
- td& { display: table-cell !important; }
+ td& { display: table-cell !important; }
}
.responsive-invisibility() {
@@ -565,6 +589,7 @@
td& { display: none !important; }
}
+
// Grid System
// -----------
@@ -574,14 +599,14 @@
margin-left: auto;
padding-left: (@grid-gutter-width / 2);
padding-right: (@grid-gutter-width / 2);
- .clearfix();
+ &:extend(.clearfix all);
}
// Creates a wrapper for a series of columns
.make-row(@gutter: @grid-gutter-width) {
margin-left: (@gutter / -2);
margin-right: (@gutter / -2);
- .clearfix();
+ &:extend(.clearfix all);
}
// Generate the extra small columns
@@ -696,6 +721,80 @@
}
+// Framework grid generation
+//
+// Used only by Bootstrap to generate the correct number of grid classes given
+// any value of `@grid-columns`.
+
+.make-grid-columns() {
+ // Common styles for all sizes of grid columns, widths 1-12
+ .col(@index) when (@index = 1) { // initial
+ @item: ~".col-xs-@{index}, .col-sm-@{index}, .col-md-@{index}, .col-lg-@{index}";
+ .col((@index + 1), @item);
+ }
+ .col(@index, @list) when (@index =< @grid-columns) { // general; "=<" isn't a typo
+ @item: ~".col-xs-@{index}, .col-sm-@{index}, .col-md-@{index}, .col-lg-@{index}";
+ .col((@index + 1), ~"@{list}, @{item}");
+ }
+ .col(@index, @list) when (@index > @grid-columns) { // terminal
+ @{list} {
+ position: relative;
+ // Prevent columns from collapsing when empty
+ min-height: 1px;
+ // Inner gutter via padding
+ padding-left: (@grid-gutter-width / 2);
+ padding-right: (@grid-gutter-width / 2);
+ }
+ }
+ .col(1); // kickstart it
+}
+
+.make-grid-columns-float(@class) {
+ .col(@index) when (@index = 1) { // initial
+ @item: ~".col-@{class}-@{index}";
+ .col((@index + 1), @item);
+ }
+ .col(@index, @list) when (@index =< @grid-columns) { // general
+ @item: ~".col-@{class}-@{index}";
+ .col((@index + 1), ~"@{list}, @{item}");
+ }
+ .col(@index, @list) when (@index > @grid-columns) { // terminal
+ @{list} {
+ float: left;
+ }
+ }
+ .col(1); // kickstart it
+}
+
+.calc-grid(@index, @class, @type) when (@type = width) and (@index > 0) {
+ .col-@{class}-@{index} {
+ width: percentage((@index / @grid-columns));
+ }
+}
+.calc-grid(@index, @class, @type) when (@type = push) {
+ .col-@{class}-push-@{index} {
+ left: percentage((@index / @grid-columns));
+ }
+}
+.calc-grid(@index, @class, @type) when (@type = pull) {
+ .col-@{class}-pull-@{index} {
+ right: percentage((@index / @grid-columns));
+ }
+}
+.calc-grid(@index, @class, @type) when (@type = offset) {
+ .col-@{class}-offset-@{index} {
+ margin-left: percentage((@index / @grid-columns));
+ }
+}
+
+// Basic looping in LESS
+.make-grid(@index, @class, @type) when (@index >= 0) {
+ .calc-grid(@index, @class, @type);
+ // next iteration
+ .make-grid((@index - 1), @class, @type);
+}
+
+
// Form validation states
//
// Used in forms.less to generate the form validation CSS for warnings, errors,
@@ -704,7 +803,11 @@
.form-control-validation(@text-color: #555; @border-color: #ccc; @background-color: #f5f5f5) {
// Color the label and help text
.help-block,
- .control-label {
+ .control-label,
+ .radio,
+ .checkbox,
+ .radio-inline,
+ .checkbox-inline {
color: @text-color;
}
// Set the border and box shadow on specific inputs to match