1

I'm trying to make the Bootstrap 4 Dropdown fade in when clicked, however I am unable to achieve this result with using transitions:

.dropdown-menu {
    -webkit-transition: 0.25s;
    transition: 0.25s;
}

Thanks!

3 Answers3

2
.dropdown .dropdown-menu{
    display: block; 
    opacity:0;
    -webkit-transition: all 200ms ease-in;
    -moz-transition: all 200ms ease-in;
    -ms-transition: all 200ms ease-in;
    -o-transition: all 200ms ease-in;
    transition: all 200ms ease-in;
 }
 .dropdown:hover .dropdown-menu {
    display: block;
    opacity: 1;
 }

Found this on the internet when I was looking for something similar on hover

1

This is a working fade transition for dropdown in Bootstrap 4:

.dropdown-menu.fade {
   display: block;
   opacity: 0;
   pointer-events: none;
}

.show > .dropdown-menu.fade {
   pointer-events: auto;
   opacity: 1;
}

Credit: https://stackoverflow.com/a/47986695/1821637

Máster
  • 981
  • 11
  • 23
0

you can try this. it will also work all the mobile devices

`@include media-breakpoint-up(xl) {
  .dropdown-on-hover {
    &.dropdown {
      .dropdown-menu{
        display: block; 
        visibility: hidden;
        opacity: 0;
        transition: visibility 0s, opacity 0.5s linear;}
      @include hover-focus {
        .dropdown-menu {
          visibility: visible;
          opacity: 1;
        }
      }
    }
  }
}`