Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove caret on Bootstrap 3 menu and show dropdown on hover?

I have set up Bootstrap 3 on my Wordpress theme and I have got the submenu working correctly on a mobile (grey arrow to indicate it is a dropdown which opens on click).

On a desktop I would like the dropdown to work on hover without the arrow image. Is there a way to do this without affecting the mobile layout? see this.

like image 297
user3050023 Avatar asked Jan 28 '26 23:01

user3050023


2 Answers

I get it, you don't want the users to see the "caret" on the desktop. This could be achieved with minimal amount of Media Queries. It should be something along these lines. I got the Desktop breakpoint Media query code right from Bootstrap 3 Docs.

@media (min-width: 1200px) {
  .navbar-nav .caret {
  display:none;
 }

 .dropdown:hover .dropdown-menu {
   display: block;
  }
}
like image 176
Ali Gajani Avatar answered Jan 30 '26 11:01

Ali Gajani


You can use Jquery hover to activate the drop-down

Try this

$(document).ready(function() {
    $('.nav li.dropdown').hover(function() {
        $(this).addClass('open');
    }, function() {
        $(this).removeClass('open');
    });
    if($(window).width() > 750)
    {
    $('b.caret').hide() 
    }
});

DEMO

like image 37
Sridhar R Avatar answered Jan 30 '26 13:01

Sridhar R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!