Skip to content

Commit

Permalink
Add basic position to dropup/right/left and dropdown-menu-right (#25400)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysds authored and XhmikosR committed Mar 12, 2018
1 parent fb15575 commit 14f7126
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
30 changes: 29 additions & 1 deletion scss/_dropdown.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// The dropdown wrapper (`<div>`)
.dropup,
.dropdown {
.dropright,
.dropdown,
.dropleft {
position: relative;
}

Expand Down Expand Up @@ -31,10 +33,17 @@
@include box-shadow($dropdown-box-shadow);
}

.dropdown-menu-right {
right: 0;
left: auto;
}

// 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 {
top: auto;
bottom: 100%;
margin-top: 0;
margin-bottom: $dropdown-spacer;
}
Expand All @@ -46,6 +55,9 @@

.dropright {
.dropdown-menu {
top: 0;
right: auto;
left: 100%;
margin-top: 0;
margin-left: $dropdown-spacer;
}
Expand All @@ -60,6 +72,9 @@

.dropleft {
.dropdown-menu {
top: 0;
right: 100%;
left: auto;
margin-top: 0;
margin-right: $dropdown-spacer;
}
Expand All @@ -72,6 +87,19 @@
}
}

// 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

// Dividers (basically an `<hr>`) within the dropdown
.dropdown-divider {
@include nav-divider($dropdown-divider-bg);
Expand Down
12 changes: 0 additions & 12 deletions scss/_navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,6 @@
position: absolute;
}

.dropdown-menu-right {
right: 0;
left: auto; // Reset the default from `.dropdown-menu`
}

.nav-link {
padding-right: $navbar-nav-link-padding-x;
padding-left: $navbar-nav-link-padding-x;
Expand All @@ -189,13 +184,6 @@
.navbar-toggler {
display: none;
}

.dropup {
.dropdown-menu {
top: auto;
bottom: 100%;
}
}
}
}
}
Expand Down

0 comments on commit 14f7126

Please sign in to comment.