blob: 06a4f527080d60601b41f27384433dd63bf235c6 [file] [log] [blame]
Matteo Scandolod2044a42017-08-07 16:08:28 -07001
2/*
3 * Copyright 2017-present Open Networking Foundation
4
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8
9 * http://www.apache.org/licenses/LICENSE-2.0
10
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18
Matteo Scandolo2500e392016-03-25 17:20:27 -070019//
20// Dropdown menus
21// --------------------------------------------------
22
23
24// Dropdown arrow/caret
25.caret {
26 display: inline-block;
27 width: 0;
28 height: 0;
29 margin-left: 2px;
30 vertical-align: middle;
31 border-top: $caret-width-base dashed;
32 border-top: $caret-width-base solid \9; // IE8
33 border-right: $caret-width-base solid transparent;
34 border-left: $caret-width-base solid transparent;
35}
36
37// The dropdown wrapper (div)
38.dropup,
39.dropdown {
40 position: relative;
41}
42
43// Prevent the focus on the dropdown toggle when closing dropdowns
44.dropdown-toggle:focus {
45 outline: 0;
46}
47
48// The dropdown menu (ul)
49.dropdown-menu {
50 position: absolute;
51 top: 100%;
52 left: 0;
53 z-index: $zindex-dropdown;
54 display: none; // none by default, but block on "open" of the menu
55 float: left;
56 min-width: 160px;
57 padding: 5px 0;
58 margin: 2px 0 0; // override default ul
59 list-style: none;
60 font-size: $font-size-base;
61 text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer)
62 background-color: $dropdown-bg;
63 border: 1px solid $dropdown-fallback-border; // IE8 fallback
64 border: 1px solid $dropdown-border;
65 border-radius: $border-radius-base;
66 @include box-shadow(0 6px 12px rgba(0,0,0,.175));
67 background-clip: padding-box;
68
69 // Aligns the dropdown menu to right
70 //
71 // Deprecated as of 3.1.0 in favor of `.dropdown-menu-[dir]`
72 &.pull-right {
73 right: 0;
74 left: auto;
75 }
76
77 // Dividers (basically an hr) within the dropdown
78 .divider {
79 @include nav-divider($dropdown-divider-bg);
80 }
81
82 // Links within the dropdown menu
83 > li > a {
84 display: block;
85 padding: 3px 20px;
86 clear: both;
87 font-weight: normal;
88 line-height: $line-height-base;
89 color: $dropdown-link-color;
90 white-space: nowrap; // prevent links from randomly breaking onto new lines
91 }
92}
93
94// Hover/Focus state
95.dropdown-menu > li > a {
96 &:hover,
97 &:focus {
98 text-decoration: none;
99 color: $dropdown-link-hover-color;
100 background-color: $dropdown-link-hover-bg;
101 }
102}
103
104// Active state
105.dropdown-menu > .active > a {
106 &,
107 &:hover,
108 &:focus {
109 color: $dropdown-link-active-color;
110 text-decoration: none;
111 outline: 0;
112 background-color: $dropdown-link-active-bg;
113 }
114}
115
116// Disabled state
117//
118// Gray out text and ensure the hover/focus state remains gray
119
120.dropdown-menu > .disabled > a {
121 &,
122 &:hover,
123 &:focus {
124 color: $dropdown-link-disabled-color;
125 }
126
127 // Nuke hover/focus effects
128 &:hover,
129 &:focus {
130 text-decoration: none;
131 background-color: transparent;
132 background-image: none; // Remove CSS gradient
133 @include reset-filter;
134 cursor: $cursor-disabled;
135 }
136}
137
138// Open state for the dropdown
139.open {
140 // Show the menu
141 > .dropdown-menu {
142 display: block;
143 }
144
145 // Remove the outline when :focus is triggered
146 > a {
147 outline: 0;
148 }
149}
150
151// Menu positioning
152//
153// Add extra class to `.dropdown-menu` to flip the alignment of the dropdown
154// menu with the parent.
155.dropdown-menu-right {
156 left: auto; // Reset the default from `.dropdown-menu`
157 right: 0;
158}
159// With v3, we enabled auto-flipping if you have a dropdown within a right
160// aligned nav component. To enable the undoing of that, we provide an override
161// to restore the default dropdown menu alignment.
162//
163// This is only for left-aligning a dropdown menu within a `.navbar-right` or
164// `.pull-right` nav component.
165.dropdown-menu-left {
166 left: 0;
167 right: auto;
168}
169
170// Dropdown section headers
171.dropdown-header {
172 display: block;
173 padding: 3px 20px;
174 font-size: $font-size-small;
175 line-height: $line-height-base;
176 color: $dropdown-header-color;
177 white-space: nowrap; // as with > li > a
178}
179
180// Backdrop to catch body clicks on mobile, etc.
181.dropdown-backdrop {
182 position: fixed;
183 left: 0;
184 right: 0;
185 bottom: 0;
186 top: 0;
187 z-index: ($zindex-dropdown - 10);
188}
189
190// Right aligned dropdowns
191.pull-right > .dropdown-menu {
192 right: 0;
193 left: auto;
194}
195
196// Allow for dropdowns to go bottom up (aka, dropup-menu)
197//
198// Just add .dropup after the standard .dropdown class and you're set, bro.
199// TODO: abstract this so that the navbar fixed styles are not placed here?
200
201.dropup,
202.navbar-fixed-bottom .dropdown {
203 // Reverse the caret
204 .caret {
205 border-top: 0;
206 border-bottom: $caret-width-base dashed;
207 border-bottom: $caret-width-base solid \9; // IE8
208 content: "";
209 }
210 // Different positioning for bottom up menu
211 .dropdown-menu {
212 top: auto;
213 bottom: 100%;
214 margin-bottom: 2px;
215 }
216}
217
218
219// Component alignment
220//
221// Reiterate per navbar.less and the modified component alignment there.
222
223@media (min-width: $grid-float-breakpoint) {
224 .navbar-right {
225 .dropdown-menu {
226 right: 0; left: auto;
227 }
228 // Necessary for overrides of the default right aligned menu.
229 // Will remove come v4 in all likelihood.
230 .dropdown-menu-left {
231 left: 0; right: auto;
232 }
233 }
234}