buttons.less 4.05 KB
Newer Older
1
2
3
//
// Buttons
// --------------------------------------------------
4

5
6

// Base styles
Mark Otto's avatar
Mark Otto committed
7
// --------------------------------------------------
8

Mark Otto's avatar
Mark Otto committed
9
// Core
10
11
.btn {
  display: inline-block;
12
  padding: 6px 12px;
13
  margin-bottom: 0; // For input.btn
Mark Otto's avatar
Mark Otto committed
14
15
  font-size: @base-font-size;
  line-height: @base-line-height;
16
  text-align: center;
17
  vertical-align: middle;
Jacob Thornton's avatar
Jacob Thornton committed
18
  cursor: pointer;
19
  .buttonBackground(@btnBackground, @btnBackgroundHighlight, @grayDark, 0 1px 1px rgba(255,255,255,.75));
20
21
  border: 1px solid @btnBorder;
  border-bottom-color: darken(@btnBorder, 10%);
22
  border-radius: @baseBorderRadius;
23
  .box-shadow(~"inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)");
24

25
26
27
28
29
  // Hover state
  &:hover {
    color: @grayDark;
    text-decoration: none;
    background-position: 0 -15px;
30

31
32
33
34
    // transition is only when going to hover, otherwise the background
    // behind the gradient (there for IE<=9 fallback) gets mismatched
    .transition(background-position .1s linear);
  }
35

36
37
38
39
  // Focus state for keyboard and accessibility
  &:focus {
    .tab-focus();
  }
40

41
42
43
44
45
  // Active state
  &.active,
  &:active {
    background-image: none;
    outline: 0;
46
    .box-shadow(~"inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)");
47
  }
48

49
50
51
52
53
54
55
56
  // Disabled state
  &.disabled,
  &[disabled] {
    cursor: default;
    background-image: none;
    .opacity(65);
    .box-shadow(none);
  }
57

Mark Otto's avatar
Mark Otto committed
58
59
60
61
}


// Button Sizes
62
// -------------------------
Mark Otto's avatar
Mark Otto committed
63
64

// Large
65
.btn-large {
66
67
  padding: @paddingLarge;
  font-size: @fontSizeLarge;
68
  border-radius: @borderRadiusLarge;
Mark Otto's avatar
Mark Otto committed
69
70
71
}

// Small
72
.btn-small {
73
74
  padding: @paddingSmall;
  font-size: @fontSizeSmall;
75
  border-radius: @borderRadiusSmall;
Mark Otto's avatar
Mark Otto committed
76
77
}

Mark Otto's avatar
Mark Otto committed
78
79
// Mini
.btn-mini {
80
81
  padding: @paddingMini;
  font-size: @fontSizeMini;
82
  border-radius: @borderRadiusSmall;
Mark Otto's avatar
Mark Otto committed
83
84
}

85

86
87
88
// Icons in buttons
// -------------------------

89
90
91
.btn [class^="glyphicon-"]::before       { vertical-align: -2px; }
.btn-small [class^="glyphicon-"]::before,
.btn-mini [class^="glyphicon-"]::before  { vertical-align: -1px; }
92
93


94
// Block button
95
96
// -------------------------

97
98
99
100
101
102
103
.btn-block {
  display: block;
  width: 100%;
  padding-left: 0;
  padding-right: 0;
  .box-sizing(border-box);
}
104
105

// Vertically space out multiple block buttons
Mark Otto's avatar
Mark Otto committed
106
107
108
.btn-block + .btn-block {
  margin-top: 5px;
}
109

110
111
112
113
114
115
116
117
118
119
// Specificity overrides
input[type="submit"],
input[type="reset"],
input[type="button"] {
  &.btn-block {
    width: 100%;
  }
}


Mark Otto's avatar
Mark Otto committed
120
121
122
123
124

// Alternate buttons
// --------------------------------------------------

// Provide *some* extra contrast for those who can get it
125
126
127
128
.btn-primary.active,
.btn-warning.active,
.btn-danger.active,
.btn-success.active,
Simon's avatar
Simon committed
129
.btn-info.active,
Mark Otto's avatar
Mark Otto committed
130
.btn-inverse.active {
Mark Otto's avatar
Mark Otto committed
131
132
133
134
135
  color: rgba(255,255,255,.75);
}

// Set the backgrounds
// -------------------------
136
.btn {
137
  // reset here as of 2.0.3 due to Recess property order
Mark Otto's avatar
Mark Otto committed
138
139
  border-color: #c5c5c5;
  border-color: rgba(0,0,0,.15) rgba(0,0,0,.15) rgba(0,0,0,.25);
140
}
141
.btn-primary {
142
  .buttonBackground(@btnPrimaryBackground, @btnPrimaryBackgroundHighlight);
143
}
Mark Otto's avatar
Mark Otto committed
144
// Warning appears are orange
145
.btn-warning {
146
  .buttonBackground(@btnWarningBackground, @btnWarningBackgroundHighlight);
Mark Otto's avatar
Mark Otto committed
147
148
}
// Danger and error appear as red
149
.btn-danger {
150
  .buttonBackground(@btnDangerBackground, @btnDangerBackgroundHighlight);
Mark Otto's avatar
Mark Otto committed
151
152
}
// Success appears as green
153
.btn-success {
154
  .buttonBackground(@btnSuccessBackground, @btnSuccessBackgroundHighlight);
Mark Otto's avatar
Mark Otto committed
155
156
}
// Info appears as a neutral blue
157
.btn-info {
158
  .buttonBackground(@btnInfoBackground, @btnInfoBackgroundHighlight);
Mark Otto's avatar
Mark Otto committed
159
}
160
161
// Inverse appears as dark gray
.btn-inverse {
162
  .buttonBackground(@btnInverseBackground, @btnInverseBackgroundHighlight);
Simon's avatar
Simon committed
163
}
Mark Otto's avatar
Mark Otto committed
164
165


166
167
168
169
170

// Link buttons
// --------------------------------------------------

// Make a button look and behave like a link
171
.btn-link,
172
173
.btn-link:active,
.btn-link[disabled] {
174
175
  background-color: transparent;
  background-image: none;
176
  .box-shadow(none);
177
178
}
.btn-link {
179
180
  border-color: transparent;
  cursor: pointer;
Mark Otto's avatar
Mark Otto committed
181
  color: @link-color;
182
  border-radius: 0;
183
184
}
.btn-link:hover {
Mark Otto's avatar
Mark Otto committed
185
  color: @link-color-hover;
186
187
188
  text-decoration: underline;
  background-color: transparent;
}
189
190
191
192
.btn-link[disabled]:hover {
  color: @grayDark;
  text-decoration: none;
}