comparison static/bootstrap/less/buttons.less @ 149:d29e2f337b00

Updated to Bootstrap 3.0.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 12 Dec 2013 21:54:04 -0800
parents a5a3d454eac9
children
comparison
equal deleted inserted replaced
148:f02e049d6546 149:d29e2f337b00
4 4
5 5
6 // Base styles 6 // Base styles
7 // -------------------------------------------------- 7 // --------------------------------------------------
8 8
9 // Core
10 .btn { 9 .btn {
11 display: inline-block; 10 display: inline-block;
12 .ie7-inline-block();
13 padding: 4px 12px;
14 margin-bottom: 0; // For input.btn 11 margin-bottom: 0; // For input.btn
15 font-size: @baseFontSize; 12 font-weight: @btn-font-weight;
16 line-height: @baseLineHeight;
17 text-align: center; 13 text-align: center;
18 vertical-align: middle; 14 vertical-align: middle;
19 cursor: pointer; 15 cursor: pointer;
20 .buttonBackground(@btnBackground, @btnBackgroundHighlight, @grayDark, 0 1px 1px rgba(255,255,255,.75)); 16 background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
21 border: 1px solid @btnBorder; 17 border: 1px solid transparent;
22 *border: 0; // Remove the border to prevent IE7's black border on input:focus 18 white-space: nowrap;
23 border-bottom-color: darken(@btnBorder, 10%); 19 .button-size(@padding-base-vertical; @padding-base-horizontal; @font-size-base; @line-height-base; @border-radius-base);
24 .border-radius(@baseBorderRadius); 20 .user-select(none);
25 .ie7-restore-left-whitespace(); // Give IE7 some love
26 .box-shadow(~"inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)");
27 21
28 // Hover/focus state
29 &:hover,
30 &:focus {
31 color: @grayDark;
32 text-decoration: none;
33 background-position: 0 -15px;
34
35 // transition is only when going to hover/focus, otherwise the background
36 // behind the gradient (there for IE<=9 fallback) gets mismatched
37 .transition(background-position .1s linear);
38 }
39
40 // Focus state for keyboard and accessibility
41 &:focus { 22 &:focus {
42 .tab-focus(); 23 .tab-focus();
43 } 24 }
44 25
45 // Active state 26 &:hover,
46 &.active, 27 &:focus {
47 &:active { 28 color: @btn-default-color;
48 background-image: none; 29 text-decoration: none;
49 outline: 0;
50 .box-shadow(~"inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)");
51 } 30 }
52 31
53 // Disabled state 32 &:active,
33 &.active {
34 outline: 0;
35 background-image: none;
36 .box-shadow(inset 0 3px 5px rgba(0,0,0,.125));
37 }
38
54 &.disabled, 39 &.disabled,
55 &[disabled] { 40 &[disabled],
56 cursor: default; 41 fieldset[disabled] & {
57 background-image: none; 42 cursor: not-allowed;
58 .opacity(65); 43 pointer-events: none; // Future-proof disabling of clicks
44 .opacity(.65);
59 .box-shadow(none); 45 .box-shadow(none);
60 } 46 }
61
62 } 47 }
63 48
49
50 // Alternate buttons
51 // --------------------------------------------------
52
53 .btn-default {
54 .button-variant(@btn-default-color; @btn-default-bg; @btn-default-border);
55 }
56 .btn-primary {
57 .button-variant(@btn-primary-color; @btn-primary-bg; @btn-primary-border);
58 }
59 // Warning appears as orange
60 .btn-warning {
61 .button-variant(@btn-warning-color; @btn-warning-bg; @btn-warning-border);
62 }
63 // Danger and error appear as red
64 .btn-danger {
65 .button-variant(@btn-danger-color; @btn-danger-bg; @btn-danger-border);
66 }
67 // Success appears as green
68 .btn-success {
69 .button-variant(@btn-success-color; @btn-success-bg; @btn-success-border);
70 }
71 // Info appears as blue-green
72 .btn-info {
73 .button-variant(@btn-info-color; @btn-info-bg; @btn-info-border);
74 }
75
76
77 // Link buttons
78 // -------------------------
79
80 // Make a button look and behave like a link
81 .btn-link {
82 color: @link-color;
83 font-weight: normal;
84 cursor: pointer;
85 border-radius: 0;
86
87 &,
88 &:active,
89 &[disabled],
90 fieldset[disabled] & {
91 background-color: transparent;
92 .box-shadow(none);
93 }
94 &,
95 &:hover,
96 &:focus,
97 &:active {
98 border-color: transparent;
99 }
100 &:hover,
101 &:focus {
102 color: @link-hover-color;
103 text-decoration: underline;
104 background-color: transparent;
105 }
106 &[disabled],
107 fieldset[disabled] & {
108 &:hover,
109 &:focus {
110 color: @btn-link-disabled-color;
111 text-decoration: none;
112 }
113 }
114 }
64 115
65 116
66 // Button Sizes 117 // Button Sizes
67 // -------------------------------------------------- 118 // --------------------------------------------------
68 119
69 // Large 120 .btn-lg {
70 .btn-large { 121 // line-height: ensure even-numbered height of button next to large input
71 padding: @paddingLarge; 122 .button-size(@padding-large-vertical; @padding-large-horizontal; @font-size-large; @line-height-large; @border-radius-large);
72 font-size: @fontSizeLarge;
73 .border-radius(@borderRadiusLarge);
74 } 123 }
75 .btn-large [class^="icon-"], 124 .btn-sm {
76 .btn-large [class*=" icon-"] { 125 // line-height: ensure proper height of button next to small input
77 margin-top: 4px; 126 .button-size(@padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @border-radius-small);
78 } 127 }
79 128 .btn-xs {
80 // Small 129 .button-size(@padding-xs-vertical; @padding-xs-horizontal; @font-size-small; @line-height-small; @border-radius-small);
81 .btn-small {
82 padding: @paddingSmall;
83 font-size: @fontSizeSmall;
84 .border-radius(@borderRadiusSmall);
85 }
86 .btn-small [class^="icon-"],
87 .btn-small [class*=" icon-"] {
88 margin-top: 0;
89 }
90 .btn-mini [class^="icon-"],
91 .btn-mini [class*=" icon-"] {
92 margin-top: -1px;
93 }
94
95 // Mini
96 .btn-mini {
97 padding: @paddingMini;
98 font-size: @fontSizeMini;
99 .border-radius(@borderRadiusSmall);
100 } 130 }
101 131
102 132
103 // Block button 133 // Block button
104 // ------------------------- 134 // --------------------------------------------------
105 135
106 .btn-block { 136 .btn-block {
107 display: block; 137 display: block;
108 width: 100%; 138 width: 100%;
109 padding-left: 0; 139 padding-left: 0;
110 padding-right: 0; 140 padding-right: 0;
111 .box-sizing(border-box);
112 } 141 }
113 142
114 // Vertically space out multiple block buttons 143 // Vertically space out multiple block buttons
115 .btn-block + .btn-block { 144 .btn-block + .btn-block {
116 margin-top: 5px; 145 margin-top: 5px;
122 input[type="button"] { 151 input[type="button"] {
123 &.btn-block { 152 &.btn-block {
124 width: 100%; 153 width: 100%;
125 } 154 }
126 } 155 }
127
128
129
130 // Alternate buttons
131 // --------------------------------------------------
132
133 // Provide *some* extra contrast for those who can get it
134 .btn-primary.active,
135 .btn-warning.active,
136 .btn-danger.active,
137 .btn-success.active,
138 .btn-info.active,
139 .btn-inverse.active {
140 color: rgba(255,255,255,.75);
141 }
142
143 // Set the backgrounds
144 // -------------------------
145 .btn-primary {
146 .buttonBackground(@btnPrimaryBackground, @btnPrimaryBackgroundHighlight);
147 }
148 // Warning appears are orange
149 .btn-warning {
150 .buttonBackground(@btnWarningBackground, @btnWarningBackgroundHighlight);
151 }
152 // Danger and error appear as red
153 .btn-danger {
154 .buttonBackground(@btnDangerBackground, @btnDangerBackgroundHighlight);
155 }
156 // Success appears as green
157 .btn-success {
158 .buttonBackground(@btnSuccessBackground, @btnSuccessBackgroundHighlight);
159 }
160 // Info appears as a neutral blue
161 .btn-info {
162 .buttonBackground(@btnInfoBackground, @btnInfoBackgroundHighlight);
163 }
164 // Inverse appears as dark gray
165 .btn-inverse {
166 .buttonBackground(@btnInverseBackground, @btnInverseBackgroundHighlight);
167 }
168
169
170 // Cross-browser Jank
171 // --------------------------------------------------
172
173 button.btn,
174 input[type="submit"].btn {
175
176 // Firefox 3.6 only I believe
177 &::-moz-focus-inner {
178 padding: 0;
179 border: 0;
180 }
181
182 // IE7 has some default padding on button controls
183 *padding-top: 3px;
184 *padding-bottom: 3px;
185
186 &.btn-large {
187 *padding-top: 7px;
188 *padding-bottom: 7px;
189 }
190 &.btn-small {
191 *padding-top: 3px;
192 *padding-bottom: 3px;
193 }
194 &.btn-mini {
195 *padding-top: 1px;
196 *padding-bottom: 1px;
197 }
198 }
199
200
201 // Link buttons
202 // --------------------------------------------------
203
204 // Make a button look and behave like a link
205 .btn-link,
206 .btn-link:active,
207 .btn-link[disabled] {
208 background-color: transparent;
209 background-image: none;
210 .box-shadow(none);
211 }
212 .btn-link {
213 border-color: transparent;
214 cursor: pointer;
215 color: @linkColor;
216 .border-radius(0);
217 }
218 .btn-link:hover,
219 .btn-link:focus {
220 color: @linkColorHover;
221 text-decoration: underline;
222 background-color: transparent;
223 }
224 .btn-link[disabled]:hover,
225 .btn-link[disabled]:focus {
226 color: @grayDark;
227 text-decoration: none;
228 }