gpt4 book ai didi

javascript - 添加 标签时 Superfish 损坏

转载 作者:太空宇宙 更新时间:2023-11-04 12:16:14 25 4
gpt4 key购买 nike

我正在使用最新的 Superfish 菜单的代码,只有当我使用没有 <a> 的列表时,我才能让它工作。标签。我可能遗漏了一些明显的东西,但我一直盯着它看太久了,我不知道出了什么问题。

这是我的 html:

<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="http://vbpmonitor.com/templates/vbpmonitor/js/superfish.js"></script>
<script src="http://vbpmonitor.com/templates/vbpmonitor/js/hoverIntent.js"> </script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('ul.sf-menu').superfish({
delay: 800, // the delay in milliseconds that the mouse can remain outside a submenu without it closing
animation: {opacity:'show'}, // an object equivalent to first parameter of jQuery’s .animate() method. Used to animate the submenu open
animationOut: {opacity:'hide'}, // an object equivalent to first parameter of jQuery’s .animate() method Used to animate the submenu closed
speed: 'normal', // speed of the opening animation. Equivalent to second parameter of jQuery’s .animate() method
speedOut: 'fast',
disableHI: true,
});
});
</script>
</head>
<body>

<nav class="navbar">
<ul class="sf-menu">
<li><a href="#">Link 1</a>
<ul>
<li><a href="#">Sublink 1</a><li>
<li><a href="#">Sublink 2</a></li>
<li><a href="#">Sublink 3</a></li>
</ul>
</li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
</nav>

</body>
</html>

CSS:

.navbar {
float: left;
width: 100%;
height: 50px;
background: #cc3333;
}
nav > ul {
margin: 0;
padding: 0;
list-style-type: none;
}
nav > ul > li {
float: left;
margin: 0;
}
nav > ul > li > a {
display: block;
padding: 17px 20px;
color: #fff;
text-decoration: none;
}
nav ul ul li a {
width: 200px;
display: block;
padding: 10px 15px;
text-decoration: none;
color: #fff;
}

/*** ESSENTIAL STYLES ***/
.sf-menu li {
position: relative;
}
.sf-menu ul {
position: absolute;
display: none;
top: 100%;
left: 0;
z-index: 99;
list-style-type:none;
}
.sf-menu > li {
float: left;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
display: block;
}

.sf-menu a {
display: block;
position: relative;
}
.sf-menu ul ul {
top: 0;
left: 100%;
}

这是我测试它的 JSbin 的链接:http://jsbin.com/mituwuxupi/1/

最佳答案

我试过你的 jsbin,它工作正常,但是看不到子菜单,只是尝试在你的 CSS 中添加一些背景,例如:

nav ul ul li a {
width: 200px;
display: block;
padding: 10px 15px;
text-decoration: none;
color: #FFF;
background-color: red;
}

您会看到您的菜单正在运行。

关于javascript - 添加 <a> 标签时 Superfish 损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28682643/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com