[英]Bootstrap fixed-top navbar with jquery hover menu tab drops
I'm learning how to use bootstrap framework on building the website. 我正在学习如何在构建网站时使用引导框架。 And there is a navbar hover effect I'd like to replicate.
我想复制一个导航栏悬停效果。 Please see the example below that provided by bootstrap.
请参阅下面的引导程序提供的示例。 https://www.aceandtate.com/ The effect is: The menu texts always show while the nav bar only drops when your mouse over the nav-bar container area.
https://www.aceandtate.com/效果是:菜单文本始终显示,而导航栏只有在鼠标悬停在导航栏容器区域上时才会放下。 Navbar white unfold drops while mouse hover
鼠标悬停时导航栏白色展开掉落
Can anyone show me how to do that? 谁能告诉我该怎么做?
Thanks, 谢谢,
First, create your dropdown with bootstrap. 首先,使用引导程序创建下拉列表。 (I assume you have index.html,css folder, and js folder in one folder).
(我假设您在一个文件夹中有index.html,css文件夹和js文件夹)。 index.html where you use bootstrap to create dropdown menu.
使用引导程序创建下拉菜单的index.html。
in your js folder, edit (create if none) your script.js file. 在您的js文件夹中,编辑(如果没有则创建)您的script.js文件。 Add this script
添加此脚本
$('ul.nav li.dropdown').hover(function() {
$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeIn(500);
}, function() {
$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeOut(500);
});
After that, include that script (if not yet include in your html file) 之后,添加该脚本(如果尚未包含在html文件中)
<script src="js/scripts.js"></script>
I place it before 我把它放在前面
</body>
Now your dropdown menu will automatic show when you hover the mouse 现在,将鼠标悬停在您的下拉菜单上会自动显示
Source : http://codepen.io/betdream/pen/frDqh 来源: http : //codepen.io/betdream/pen/frDqh
Try this for on menu dropdown hover: 在菜单下拉悬停上尝试以下操作:
Add this JS:
添加此JS:
$('ul.nav li.dropdown').hover(function() {
$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeIn(500);
}, function() {
$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeOut(500);
});
If you want to show menu always open in mobile device then add media query in your CSS file and set property display:block
如果要显示菜单始终在移动设备中打开,则在CSS文件中添加媒体查询并设置属性
display:block
For media query check this for your reference MEDIA QUERIES FOR COMMON DEVICE 对于媒体查询,请检查此内容以供参考常见设备的媒体查询
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.