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

7
8
.dropdown-toggle {
  // Generate the caret automatically
9
  &::after {
10
11
12
    display: inline-block;
    width: 0;
    height: 0;
13
    margin-left: $caret-width;
14
    vertical-align: middle;
15
    content: "";
16
17
18
    border-top: $caret-width solid;
    border-right: $caret-width solid transparent;
    border-left: $caret-width solid transparent;
19
  }
Mark Otto's avatar
Mark Otto committed
20
21
}

22
23
.dropup {
  .dropdown-toggle {
24
    &::after {
Mark Otto's avatar
shorter    
Mark Otto committed
25
      border-top: 0;
Felipe's avatar
Felipe committed
26
      border-bottom: $caret-width solid;
27
28
29
30
    }
  }
}

31
// The dropdown menu
32
33
.dropdown-menu {
  position: absolute;
34
  top: 100%;
35
  left: 0;
Mark Otto's avatar
Mark Otto committed
36
  z-index: $zindex-dropdown;
37
  display: none; // none by default, but block on "open" of the menu
Jacob Thornton's avatar
Jacob Thornton committed
38
  float: left;
39
  min-width: $dropdown-min-width;
40
  padding: $dropdown-padding-y 0;
41
  margin: $dropdown-margin-top 0 0; // override default ul
42
  font-size: $font-size-base; // Redeclare because nesting can cause inheritance issues
43
  color: $body-color;
44
  text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer)
45
  list-style: none;
Mark Otto's avatar
Mark Otto committed
46
  background-color: $dropdown-bg;
47
  background-clip: padding-box;
48
  border: $dropdown-border-width solid $dropdown-border-color;
49
  @include border-radius($border-radius);
50
  @include box-shadow($dropdown-box-shadow);
Mark Otto's avatar
Mark Otto committed
51
}
52

53
// Dividers (basically an `<hr>`) within the dropdown
Mark Otto's avatar
Mark Otto committed
54
55
.dropdown-divider {
  @include nav-divider($dropdown-divider-bg);
56
}
57

Mark Otto's avatar
Mark Otto committed
58
// Links, buttons, and more within the dropdown menu
Mark Otto's avatar
Mark Otto committed
59
//
60
// `<button>`-specific styles are denoted with `// For <button>s`
Mark Otto's avatar
Mark Otto committed
61
62
.dropdown-item {
  display: block;
Mark Otto's avatar
Mark Otto committed
63
  width: 100%; // For `<button>`s
64
  padding: 3px $dropdown-item-padding-x;
Mark Otto's avatar
Mark Otto committed
65
  clear: both;
66
  font-weight: $font-weight-normal;
Mark Otto's avatar
Mark Otto committed
67
  color: $dropdown-link-color;
Mark Otto's avatar
Mark Otto committed
68
  text-align: inherit; // For `<button>`s
Mark Otto's avatar
Mark Otto committed
69
  white-space: nowrap; // prevent links from randomly breaking onto new lines
Mark Otto's avatar
Mark Otto committed
70
71
  background: none; // For `<button>`s
  border: 0; // For `<button>`s
72

73
  @include hover-focus {
Mark Otto's avatar
Mark Otto committed
74
    color: $dropdown-link-hover-color;
75
    text-decoration: none;
Mark Otto's avatar
Mark Otto committed
76
    background-color: $dropdown-link-hover-bg;
77
  }
78

Mark Otto's avatar
Mark Otto committed
79
80
81
82
83
  &.active,
  &:active {
    color: $dropdown-link-active-color;
    text-decoration: none;
    background-color: $dropdown-link-active-bg;
84
  }
85

Mark Otto's avatar
Mark Otto committed
86
87
88
89
90
91
92
93
  &.disabled,
  &:disabled {
    color: $dropdown-link-disabled-color;
    cursor: $cursor-disabled;
    background-color: transparent;
    // Remove CSS gradients if they're enabled
    @if $enable-gradients {
      background-image: none;
Mark Otto's avatar
Mark Otto committed
94
    }
95
  }
96
97
}

98
// Open state for the dropdown
Starsam80's avatar
Starsam80 committed
99
.show {
100
101
  // Show the menu
  > .dropdown-menu {
102
103
    display: block;
  }
104
105
106
107
108

  // Remove the outline when :focus is triggered
  > a {
    outline: 0;
  }
109
}
110

111
112
113
114
115
116
// Menu positioning
//
// Add extra class to `.dropdown-menu` to flip the alignment of the dropdown
// menu with the parent.
.dropdown-menu-right {
  right: 0;
117
  left: auto; // Reset the default from `.dropdown-menu`
118
}
Mark Otto's avatar
Mark Otto committed
119

120
121
.dropdown-menu-left {
  right: auto;
122
  left: 0;
123
124
}

125
126
127
// Dropdown section headers
.dropdown-header {
  display: block;
128
  padding: $dropdown-padding-y $dropdown-item-padding-x;
Mark Otto's avatar
Mark Otto committed
129
  margin-bottom: 0; // for use with heading elements
Mark Otto's avatar
Mark Otto committed
130
131
  font-size: $font-size-sm;
  color: $dropdown-header-color;
132
  white-space: nowrap; // as with > li > a
133
134
}

135
136
137
// Backdrop to catch body clicks on mobile, etc.
.dropdown-backdrop {
  position: fixed;
138
  top: 0;
139
140
  right: 0;
  bottom: 0;
141
  left: 0;
142
  z-index: $zindex-dropdown-backdrop;
143
144
}

145
// Allow for dropdowns to go bottom up (aka, dropup-menu)
146
//
Matthew Conlen's avatar
Matthew Conlen committed
147
// Just add .dropup after the standard .dropdown class and you're set.
148

149
.dropup {
150
151
152
153
  // Different positioning for bottom up menu
  .dropdown-menu {
    top: auto;
    bottom: 100%;
154
    margin-bottom: $dropdown-margin-top;
155
156
  }
}