buttons.less 3.37 KB
Newer Older
1
2
3
// BUTTON STYLES
// -------------

4
5

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

Mark Otto's avatar
Mark Otto committed
8
// Core
9
10
.btn {
  display: inline-block;
11
  padding: 4px 10px 4px;
12
  margin-bottom: 0; // For input.btn
13
  font-size: @baseFontSize;
14
  line-height: @baseLineHeight;
15
  color: @grayDark;
16
  text-align: center;
17
  text-shadow: 0 1px 1px rgba(255,255,255,.75);
18
  vertical-align: middle;
19
  .buttonBackground(@white, darken(@white, 10%));
20
21
22
23
24
25
26
  border: 1px solid #ccc;
  border-bottom-color: #bbb;
  .border-radius(4px);
  @shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);
  .box-shadow(@shadow);
  cursor: pointer;

Mark Otto's avatar
Mark Otto committed
27
  // Give IE7 some love
28
  .reset-filter();
29
  .ie7-restore-left-whitespace();
Mark Otto's avatar
Mark Otto committed
30
}
31

Mark Otto's avatar
Mark Otto committed
32
33
34
35
36
37
// Hover state
.btn:hover {
  color: @grayDark;
  text-decoration: none;
  background-color: darken(@white, 10%);
  background-position: 0 -15px;
38

Mark Otto's avatar
Mark Otto committed
39
40
41
42
  // 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);
}
43

Mark Otto's avatar
Mark Otto committed
44
45
46
47
// Focus state for keyboard and accessibility
.btn:focus {
  .tab-focus();
}
48

Mark Otto's avatar
Mark Otto committed
49
// Active state
50
.btn.active,
Mark Otto's avatar
Mark Otto committed
51
52
53
54
55
56
57
58
.btn:active {
  background-image: none;
  @shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
  .box-shadow(@shadow);
  background-color: darken(@white, 10%);
  background-color: darken(@white, 15%) e("\9");
  outline: 0;
}
59

Mark Otto's avatar
Mark Otto committed
60
// Disabled state
61
.btn.disabled,
Mark Otto's avatar
Mark Otto committed
62
63
64
65
66
67
68
69
70
71
72
73
74
.btn[disabled] {
  cursor: default;
  background-image: none;
  background-color: darken(@white, 10%);
  .opacity(65);
  .box-shadow(none);
}


// Button Sizes
// --------------------------------------------------

// Large
75
.btn-large {
Mark Otto's avatar
Mark Otto committed
76
77
78
79
80
  padding: 9px 14px;
  font-size: @baseFontSize + 2px;
  line-height: normal;
  .border-radius(5px);
}
81
.btn-large [class^="icon-"] {
Mark Otto's avatar
Mark Otto committed
82
83
84
85
  margin-top: 1px;
}

// Small
86
.btn-small {
Mark Otto's avatar
Mark Otto committed
87
88
89
90
  padding: 5px 9px;
  font-size: @baseFontSize - 2px;
  line-height: @baseLineHeight - 2px;
}
91
.btn-small [class^="icon-"] {
Mark Otto's avatar
Mark Otto committed
92
93
94
95
96
97
98
99
100
  margin-top: -1px;
}


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

// Set text color
// -------------------------
101
102
103
104
105
106
107
108
109
110
.btn-primary,
.btn-primary:hover,
.btn-warning,
.btn-warning:hover,
.btn-danger,
.btn-danger:hover,
.btn-success,
.btn-success:hover,
.btn-info,
.btn-info:hover {
Mark Otto's avatar
Mark Otto committed
111
  text-shadow: 0 -1px 0 rgba(0,0,0,.25);
Mark Otto's avatar
Mark Otto committed
112
  color: @white;
Mark Otto's avatar
Mark Otto committed
113
114
}
// Provide *some* extra contrast for those who can get it
115
116
117
118
119
.btn-primary.active,
.btn-warning.active,
.btn-danger.active,
.btn-success.active,
.btn-info.active {
Mark Otto's avatar
Mark Otto committed
120
121
122
123
124
  color: rgba(255,255,255,.75);
}

// Set the backgrounds
// -------------------------
125
.btn-primary {
Mark Otto's avatar
Mark Otto committed
126
  .buttonBackground(@primaryButtonBackground, spin(@primaryButtonBackground, 20));
127
}
Mark Otto's avatar
Mark Otto committed
128
// Warning appears are orange
129
.btn-warning {
Mark Otto's avatar
Mark Otto committed
130
131
132
  .buttonBackground(lighten(@orange, 15%), @orange);
}
// Danger and error appear as red
133
.btn-danger {
Mark Otto's avatar
Mark Otto committed
134
135
136
  .buttonBackground(#ee5f5b, #bd362f);
}
// Success appears as green
137
.btn-success {
Mark Otto's avatar
Mark Otto committed
138
139
140
  .buttonBackground(#62c462, #51a351);
}
// Info appears as a neutral blue
141
.btn-info {
Mark Otto's avatar
Mark Otto committed
142
143
144
145
146
147
  .buttonBackground(#5bc0de, #2f96b4);
}


// Cross-browser Jank
// --------------------------------------------------
148
149

button.btn,
150
input[type="submit"].btn {
151
  &::-moz-focus-inner {
152
    padding: 0;
Mark Otto's avatar
Mark Otto committed
153
    border: 0;
154
  }
155
156
157
158
159
160
161
162
163
164
165
166

  // IE7 has some default padding on button controls
  *padding-top: 2px;
  *padding-bottom: 2px;
  &.large {
    *padding-top: 7px;
    *padding-bottom: 7px;
  }
  &.small {
    *padding-top: 3px;
    *padding-bottom: 3px;
  }
167
}