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

5

6
7
// Dropdown arrow/caret
.caret {
8
9
  display: inline-block;
  width: 0;
10
  height: 0;
11
12
  margin-left: 2px;
  vertical-align: middle;
13
  border-top:   @caret-width-base dashed;
14
15
  border-right: @caret-width-base solid transparent;
  border-left:  @caret-width-base solid transparent;
16
}
17

Guillermo González de Agüero's avatar
Guillermo González de Agüero committed
18
// The dropdown wrapper (div)
19
.dropup,
Guillermo González de Agüero's avatar
Guillermo González de Agüero committed
20
21
22
23
.dropdown {
  position: relative;
}

Mark Otto's avatar
Mark Otto committed
24
25
26
27
28
// Prevent the focus on the dropdown toggle when closing dropdowns
.dropdown-toggle:focus {
  outline: 0;
}

29
30
31
// The dropdown menu (ul)
.dropdown-menu {
  position: absolute;
32
  top: 100%;
33
  left: 0;
34
  z-index: @zindex-dropdown;
35
  display: none; // none by default, but block on "open" of the menu
Jacob Thornton's avatar
Jacob Thornton committed
36
  float: left;
37
  min-width: 160px;
Mark Otto's avatar
Mark Otto committed
38
  padding: 5px 0;
Mark Otto's avatar
Mark Otto committed
39
  margin: 2px 0 0; // override default ul
40
  list-style: none;
41
  font-size: @font-size-base;
42
  text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer)
Mark Otto's avatar
Mark Otto committed
43
  background-color: @dropdown-bg;
44
  border: 1px solid @dropdown-fallback-border; // IE8 fallback
Mark Otto's avatar
Mark Otto committed
45
  border: 1px solid @dropdown-border;
46
  border-radius: @border-radius-base;
47
  .box-shadow(0 6px 12px rgba(0,0,0,.175));
48
  background-clip: padding-box;
49

50
  // Aligns the dropdown menu to right
51
  //
Chris Rebert's avatar
Chris Rebert committed
52
  // Deprecated as of 3.1.0 in favor of `.dropdown-menu-[dir]`
53
54
55
  &.pull-right {
    right: 0;
    left: auto;
56
57
  }

58
59
  // Dividers (basically an hr) within the dropdown
  .divider {
Mark Otto's avatar
Mark Otto committed
60
    .nav-divider(@dropdown-divider-bg);
61
62
63
  }

  // Links within the dropdown menu
64
  > li > a {
65
    display: block;
66
    padding: 3px 20px;
67
68
    clear: both;
    font-weight: normal;
69
    line-height: @line-height-base;
Mark Otto's avatar
Mark Otto committed
70
    color: @dropdown-link-color;
71
    white-space: nowrap; // prevent links from randomly breaking onto new lines
72
  }
73
}
74

75
// Hover/Focus state
76
77
78
79
80
.dropdown-menu > li > a {
  &:hover,
  &:focus {
    text-decoration: none;
    color: @dropdown-link-hover-color;
81
    background-color: @dropdown-link-hover-bg;
82
  }
83
84
85
}

// Active state
86
87
88
89
90
91
92
.dropdown-menu > .active > a {
  &,
  &:hover,
  &:focus {
    color: @dropdown-link-active-color;
    text-decoration: none;
    outline: 0;
93
    background-color: @dropdown-link-active-bg;
94
  }
95
96
}

97
// Disabled state
98
//
99
// Gray out text and ensure the hover/focus state remains gray
100

101
102
103
104
.dropdown-menu > .disabled > a {
  &,
  &:hover,
  &:focus {
105
    color: @dropdown-link-disabled-color;
106
  }
vsn4ik's avatar
vsn4ik committed
107
108

  // Nuke hover/focus effects
109
110
111
112
113
114
  &:hover,
  &:focus {
    text-decoration: none;
    background-color: transparent;
    background-image: none; // Remove CSS gradient
    .reset-filter();
115
    cursor: @cursor-disabled;
116
  }
117
118
}

119
// Open state for the dropdown
Mark Otto's avatar
Mark Otto committed
120
.open {
121
122
  // Show the menu
  > .dropdown-menu {
123
124
    display: block;
  }
125
126
127
128
129

  // Remove the outline when :focus is triggered
  > a {
    outline: 0;
  }
130
}
131

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Menu positioning
//
// Add extra class to `.dropdown-menu` to flip the alignment of the dropdown
// menu with the parent.
.dropdown-menu-right {
  left: auto; // Reset the default from `.dropdown-menu`
  right: 0;
}
// With v3, we enabled auto-flipping if you have a dropdown within a right
// aligned nav component. To enable the undoing of that, we provide an override
// to restore the default dropdown menu alignment.
//
// This is only for left-aligning a dropdown menu within a `.navbar-right` or
// `.pull-right` nav component.
.dropdown-menu-left {
  left: 0;
  right: auto;
}

151
152
153
154
155
156
// Dropdown section headers
.dropdown-header {
  display: block;
  padding: 3px 20px;
  font-size: @font-size-small;
  line-height: @line-height-base;
157
  color: @dropdown-header-color;
158
  white-space: nowrap; // as with > li > a
159
160
}

161
162
163
164
165
166
167
// Backdrop to catch body clicks on mobile, etc.
.dropdown-backdrop {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
168
  z-index: (@zindex-dropdown - 10);
169
170
}

Mark Otto's avatar
Mark Otto committed
171
// Right aligned dropdowns
172
.pull-right > .dropdown-menu {
Mark Otto's avatar
Mark Otto committed
173
  right: 0;
Jacob Thornton's avatar
Jacob Thornton committed
174
  left: auto;
Mark Otto's avatar
Mark Otto committed
175
176
}

177
// Allow for dropdowns to go bottom up (aka, dropup-menu)
178
//
179
// Just add .dropup after the standard .dropdown class and you're set, bro.
180
// TODO: abstract this so that the navbar fixed styles are not placed here?
181

182
183
.dropup,
.navbar-fixed-bottom .dropdown {
184
185
  // Reverse the caret
  .caret {
186
    border-top: 0;
187
    border-bottom: @caret-width-base solid;
188
    content: "";
189
190
191
192
193
  }
  // Different positioning for bottom up menu
  .dropdown-menu {
    top: auto;
    bottom: 100%;
194
    margin-bottom: 2px;
195
196
  }
}
197
198
199
200
201
202
203
204
205


// Component alignment
//
// Reiterate per navbar.less and the modified component alignment there.

@media (min-width: @grid-float-breakpoint) {
  .navbar-right {
    .dropdown-menu {
206
207
208
209
210
211
      .dropdown-menu-right();
    }
    // Necessary for overrides of the default right aligned menu.
    // Will remove come v4 in all likelihood.
    .dropdown-menu-left {
      .dropdown-menu-left();
212
213
214
    }
  }
}