dropdowns.less 5.51 KB
Newer Older
1
2
3
4
//
// Dropdown menus
// --------------------------------------------------

5

6
// Use the .menu class on any <li> element within the topbar or ul.tabs and you'll get some superfancy dropdowns
Mark Otto's avatar
Mark Otto committed
7
.dropup,
8
9
10
.dropdown {
  position: relative;
}
11
.dropdown-toggle {
12
13
14
  // The caret makes the toggle a bit too tall in IE7
  *margin-bottom: -3px;
}
15
16
17
18
.dropdown-toggle:active,
.open .dropdown-toggle {
  outline: 0;
}
19

20
// Dropdown arrow/caret
21
// --------------------
22
.caret {
23
24
  display: inline-block;
  width: 0;
25
26
  height: 0;
  vertical-align: top;
27
  border-top:   4px solid @black;
Jacob Thornton's avatar
Jacob Thornton committed
28
29
  border-right: 4px solid transparent;
  border-left:  4px solid transparent;
30
  content: "";
31
}
32

33
// Place the caret
34
.dropdown .caret {
35
  margin-top: 8px;
36
37
  margin-left: 2px;
}
38

39
// The dropdown menu (ul)
40
// ----------------------
41
42
.dropdown-menu {
  position: absolute;
43
  top: 100%;
44
  left: 0;
45
  z-index: @zindexDropdown;
46
  display: none; // none by default, but block on "open" of the menu
Jacob Thornton's avatar
Jacob Thornton committed
47
  float: left;
48
  min-width: 160px;
Mark Otto's avatar
Mark Otto committed
49
  padding: 5px 0;
Mark Otto's avatar
Mark Otto committed
50
  margin: 2px 0 0; // override default ul
51
  list-style: none;
Mark Otto's avatar
Mark Otto committed
52
  background-color: @dropdownBackground;
53
54
  border: 1px solid #ccc; // Fallback for IE7-8
  border: 1px solid @dropdownBorder;
Jacob Thornton's avatar
Jacob Thornton committed
55
56
  *border-right-width: 2px;
  *border-bottom-width: 2px;
Mark Otto's avatar
Mark Otto committed
57
  .border-radius(6px);
58
59
60
61
  .box-shadow(0 5px 10px rgba(0,0,0,.2));
  -webkit-background-clip: padding-box;
     -moz-background-clip: padding;
          background-clip: padding-box;
62

63
64
65
66
  // Aligns the dropdown menu to right
  &.pull-right {
    right: 0;
    left: auto;
67
68
  }

69
70
  // Dividers (basically an hr) within the dropdown
  .divider {
71
    .nav-divider(@dropdownDividerTop, @dropdownDividerBottom);
72
73
74
  }

  // Links within the dropdown menu
75
  li > a {
76
    display: block;
77
    padding: 3px 20px;
78
79
    clear: both;
    font-weight: normal;
Mark Otto's avatar
Mark Otto committed
80
    line-height: @baseLineHeight;
Mark Otto's avatar
Mark Otto committed
81
    color: @dropdownLinkColor;
82
    white-space: nowrap;
83
  }
84
}
85

86
// Hover state
87
// -----------
88
.dropdown-menu li > a:hover,
89
90
.dropdown-menu li > a:focus,
.dropdown-submenu:hover > a {
91
  text-decoration: none;
92
  color: @dropdownLinkColorHover;
93
  background-color: @dropdownLinkBackgroundHover;
94
  #gradient > .vertical(@dropdownLinkBackgroundHover, darken(@dropdownLinkBackgroundHover, 5%));
95
96
97
98
}

// Active state
// ------------
99
100
.dropdown-menu .active > a,
.dropdown-menu .active > a:hover {
Mark Otto's avatar
Mark Otto committed
101
  color: @dropdownLinkColorHover;
102
  text-decoration: none;
103
  outline: 0;
104
105
  background-color: @dropdownLinkBackgroundActive;
  #gradient > .vertical(@dropdownLinkBackgroundActive, darken(@dropdownLinkBackgroundActive, 5%));
106
107
}

108
109
110
111
112
113
114
115
116
117
118
// Disabled state
// --------------
// Gray out text and ensure the hover state remains gray
.dropdown-menu .disabled > a,
.dropdown-menu .disabled > a:hover {
  color: @grayLight;
}
// Nuke hover effects
.dropdown-menu .disabled > a:hover {
  text-decoration: none;
  background-color: transparent;
119
  background-image: none; // Remove CSS gradient
120
121
122
  cursor: default;
}

123
// Open state for the dropdown
124
// ---------------------------
Mark Otto's avatar
Mark Otto committed
125
.open {
126
127
128
129
  // IE7's z-index only goes to the nearest positioned ancestor, which would
  // make the menu appear below buttons that appeared later on the page
  *z-index: @zindexDropdown;

130
  & > .dropdown-menu {
131
132
133
    display: block;
  }
}
134

Mark Otto's avatar
Mark Otto committed
135
// Right aligned dropdowns
Mark Otto's avatar
Mark Otto committed
136
// ---------------------------
137
.pull-right > .dropdown-menu {
Mark Otto's avatar
Mark Otto committed
138
  right: 0;
Jacob Thornton's avatar
Jacob Thornton committed
139
  left: auto;
Mark Otto's avatar
Mark Otto committed
140
141
}

142
143
144
// Allow for dropdowns to go bottom up (aka, dropup-menu)
// ------------------------------------------------------
// Just add .dropup after the standard .dropdown class and you're set, bro.
145
146
147
// TODO: abstract this so that the navbar fixed styles are not placed here?
.dropup,
.navbar-fixed-bottom .dropdown {
148
149
150
151
  // Reverse the caret
  .caret {
    border-top: 0;
    border-bottom: 4px solid @black;
152
    content: "";
153
154
155
156
157
158
159
160
161
  }
  // Different positioning for bottom up menu
  .dropdown-menu {
    top: auto;
    bottom: 100%;
    margin-bottom: 1px;
  }
}

162
163
164
165
166
// Sub menus
// ---------------------------
.dropdown-submenu {
  position: relative;
}
167
// Default dropdowns
168
169
170
.dropdown-submenu > .dropdown-menu {
  top: 0;
  left: 100%;
171
  margin-top: -6px;
172
173
174
175
176
  margin-left: -1px;
  -webkit-border-radius: 0 6px 6px 6px;
     -moz-border-radius: 0 6px 6px 6px;
          border-radius: 0 6px 6px 6px;
}
177
.dropdown-submenu:hover > .dropdown-menu {
178
179
180
  display: block;
}

181
182
183
184
185
186
187
188
189
190
191
192
// Dropups
.dropup .dropdown-submenu > .dropdown-menu {
  top: auto;
  bottom: 0;
  margin-top: 0;
  margin-bottom: -2px;
  -webkit-border-radius: 5px 5px 5px 0;
     -moz-border-radius: 5px 5px 5px 0;
          border-radius: 5px 5px 5px 0;
}

// Caret to indicate there is a submenu
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
.dropdown-submenu > a:after {
  display: block;
  content: " ";
  float: right;
  width: 0;
  height: 0;
  border-color: transparent;
  border-style: solid;
  border-width: 5px 0 5px 5px;
  border-left-color: darken(@dropdownBackground, 20%);
  margin-top: 5px;
  margin-right: -10px;
}
.dropdown-submenu:hover > a:after {
  border-left-color: @dropdownLinkColorHover;
}

210
211
212
213
214
215
216
217
218
219
220
221
222
223
// Left aligned submenus
.dropdown-submenu.pull-left {
  // Undo the float
  // Yes, this is awkward since .pull-left adds a float, but it sticks to our conventions elsewhere.
  float: none;

  // Positioning the submenu
  > .dropdown-menu {
    left: -100%;
    margin-left: 10px;
    -webkit-border-radius: 6px 0 6px 6px;
       -moz-border-radius: 6px 0 6px 6px;
            border-radius: 6px 0 6px 6px;
  }
224
}
225
226
227
228
229
230
231
232
233

// Tweak nav headers
// -----------------
// Increase padding from 15px to 20px on sides
.dropdown .dropdown-menu .nav-header {
  padding-left: 20px;
  padding-right: 20px;
}

234
// Typeahead
235
// ---------
236
237
.typeahead {
  margin-top: 2px; // give it some space to breathe
238
  .border-radius(@baseBorderRadius);
239
}