_dropdown.scss 3.69 KB
Newer Older
1
// The dropdown wrapper (`<div>`)
2
.dropup,
3
4
5
.dropright,
.dropdown,
.dropleft {
Guillermo González de Agüero's avatar
Guillermo González de Agüero committed
6
7
8
  position: relative;
}

9
10
.dropdown-toggle {
  // Generate the caret automatically
11
  @include caret;
Mark Otto's avatar
Mark Otto committed
12
13
}

14
// The dropdown menu
15
16
.dropdown-menu {
  position: absolute;
17
  top: 100%;
18
  left: 0;
Mark Otto's avatar
Mark Otto committed
19
  z-index: $zindex-dropdown;
20
  display: none; // none by default, but block on "open" of the menu
Jacob Thornton's avatar
Jacob Thornton committed
21
  float: left;
22
  min-width: $dropdown-min-width;
23
  padding: $dropdown-padding-y 0;
24
  margin: $dropdown-spacer 0 0; // override default ul
25
  font-size: $font-size-base; // Redeclare because nesting can cause inheritance issues
26
  color: $body-color;
27
  text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer)
28
  list-style: none;
Mark Otto's avatar
Mark Otto committed
29
  background-color: $dropdown-bg;
30
  background-clip: padding-box;
31
  border: $dropdown-border-width solid $dropdown-border-color;
32
  @include border-radius($dropdown-border-radius);
33
  @include box-shadow($dropdown-box-shadow);
Mark Otto's avatar
Mark Otto committed
34
}
35

36
37
38
39
40
.dropdown-menu-right {
  right: 0;
  left: auto;
}

41
42
43
44
// Allow for dropdowns to go bottom up (aka, dropup-menu)
// Just add .dropup after the standard .dropdown class and you're set.
.dropup {
  .dropdown-menu {
45
46
    top: auto;
    bottom: 100%;
47
48
49
50
51
52
53
54
55
    margin-top: 0;
    margin-bottom: $dropdown-spacer;
  }

  .dropdown-toggle {
    @include caret(up);
  }
}

56
57
.dropright {
  .dropdown-menu {
58
59
60
    top: 0;
    right: auto;
    left: 100%;
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    margin-top: 0;
    margin-left: $dropdown-spacer;
  }

  .dropdown-toggle {
    @include caret(right);
    &::after {
      vertical-align: 0;
    }
  }
}

.dropleft {
  .dropdown-menu {
75
76
77
    top: 0;
    right: 100%;
    left: auto;
78
79
80
81
82
83
84
85
86
87
88
89
    margin-top: 0;
    margin-right: $dropdown-spacer;
  }

  .dropdown-toggle {
    @include caret(left);
    &::before {
      vertical-align: 0;
    }
  }
}

90
91
92
93
94
95
96
97
98
99
100
101
102
// When enabled Popper.js, reset basic dropdown position
// stylelint-disable no-duplicate-selectors
.dropdown-menu {
  &[x-placement^="top"],
  &[x-placement^="right"],
  &[x-placement^="bottom"],
  &[x-placement^="left"] {
    right: auto;
    bottom: auto;
  }
}
// stylelint-enable no-duplicate-selectors

103
// Dividers (basically an `<hr>`) within the dropdown
Mark Otto's avatar
Mark Otto committed
104
105
.dropdown-divider {
  @include nav-divider($dropdown-divider-bg);
106
}
107

Mark Otto's avatar
Mark Otto committed
108
// Links, buttons, and more within the dropdown menu
Mark Otto's avatar
Mark Otto committed
109
//
110
// `<button>`-specific styles are denoted with `// For <button>s`
Mark Otto's avatar
Mark Otto committed
111
112
.dropdown-item {
  display: block;
Mark Otto's avatar
Mark Otto committed
113
  width: 100%; // For `<button>`s
Mark Otto's avatar
Mark Otto committed
114
  padding: $dropdown-item-padding-y $dropdown-item-padding-x;
Mark Otto's avatar
Mark Otto committed
115
  clear: both;
116
  font-weight: $font-weight-normal;
Mark Otto's avatar
Mark Otto committed
117
  color: $dropdown-link-color;
Mark Otto's avatar
Mark Otto committed
118
  text-align: inherit; // For `<button>`s
Mark Otto's avatar
Mark Otto committed
119
  white-space: nowrap; // prevent links from randomly breaking onto new lines
120
  background-color: transparent; // For `<button>`s
Mark Otto's avatar
Mark Otto committed
121
  border: 0; // For `<button>`s
122

123
  @include hover-focus {
Mark Otto's avatar
Mark Otto committed
124
    color: $dropdown-link-hover-color;
125
    text-decoration: none;
Mark Otto's avatar
Mark Otto committed
126
    @include gradient-bg($dropdown-link-hover-bg);
127
  }
128

Mark Otto's avatar
Mark Otto committed
129
130
131
132
  &.active,
  &:active {
    color: $dropdown-link-active-color;
    text-decoration: none;
Mark Otto's avatar
Mark Otto committed
133
    @include gradient-bg($dropdown-link-active-bg);
134
  }
135

Mark Otto's avatar
Mark Otto committed
136
137
138
  &.disabled,
  &:disabled {
    color: $dropdown-link-disabled-color;
139
    pointer-events: none;
Mark Otto's avatar
Mark Otto committed
140
141
142
143
    background-color: transparent;
    // Remove CSS gradients if they're enabled
    @if $enable-gradients {
      background-image: none;
Mark Otto's avatar
Mark Otto committed
144
    }
145
  }
146
147
}

Johann-S's avatar
Johann-S committed
148
149
150
151
.dropdown-menu.show {
  display: block;
}

152
153
154
// Dropdown section headers
.dropdown-header {
  display: block;
155
  padding: $dropdown-padding-y $dropdown-item-padding-x;
Mark Otto's avatar
Mark Otto committed
156
  margin-bottom: 0; // for use with heading elements
Mark Otto's avatar
Mark Otto committed
157
158
  font-size: $font-size-sm;
  color: $dropdown-header-color;
159
  white-space: nowrap; // as with > li > a
160
}
161
162
163
164
165
166
167

// Dropdown text
.dropdown-item-text {
  display: block;
  padding: $dropdown-item-padding-y $dropdown-item-padding-x;
  color: $dropdown-link-color;
}