Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make CSS hover state remain after unhovering

How can I make the hover state remain for at least 1 second? Currently it is difficult to select the sub menu items as the hover state disappears too soon.

Here is the jsFiddle.

My HTML:

<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div>
                <span>Logo+Text</span>
            </div>
            <div class="btn-group has_dropdown" style="margin-left: 200px">
                <a href="#" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Lists</a>
                <ul class="dropdown-menu" role="menu">
                    <li>
                        <a href="#">Sub List 1</a>
                    </li>
                    <li>
                        <a href="#">Sub List 2</a>
                    </li>
                    <li>
                        <a href="#">Sub List 3</a>
                    </li>
                    <li>
                        <a href="#">Sub List 4</a>
                    </li>
                    <li>
                        <a href="#">Sub List 5</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>

And CSS:

#headerDropdown .dropdown:hover .dropdown-menu,
.btn-group:hover .dropdown-menu {
    display: inline-flex !important;
}
like image 698
user2281858 Avatar asked Mar 13 '23 11:03

user2281858


1 Answers

You can use CSS transition with delay. But you can't use it with display property, So do it with visibility instead.

.btn-group .dropdown-menu {
  display: inline-flex;
  transition: all 0s ease 1s; /*delay 1s*/
  visibility: hidden;
}
.btn-group:hover .dropdown-menu {
  transition-delay: 0s;
  visibility: visible;
}

Updated jsFiddle

like image 63
Stickers Avatar answered Apr 01 '23 02:04

Stickers