Last active
November 7, 2021 02:53
-
-
Save kevinruscoe/c70a0ff84ac431b4abde to your computer and use it in GitHub Desktop.
Make Bootstrap 3 navigation hover on desktop, but click on mobile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function($){ | |
$("ul li").click(function(event){ | |
if( $(window).width() > 768 && event.target.className == "dropdown-toggle" ){ | |
return false; | |
} | |
}); | |
$(window).resize(function(){ | |
if( $(window).width() > 768 ){ | |
$("ul.dropdown-menu").css({display:'none'}); | |
$("li.dropdown.open").removeClass('open'); | |
}else{ | |
$("ul.dropdown-menu").removeAttr('style'); | |
} | |
}); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.nav>li>a:focus {background:none} | |
@media (min-width: 768px) { | |
#nav .navbar li:hover ul.dropdown-menu {visibility: visible;display:block!important} | |
#nav .navbar li span {display:none} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment