我正在尝试使用下面的 HTML、CSS 和 Javascript 代码呈现水平子菜单。
当我点击这两个选项时,菜单不会显示出来。基本上什么都没有出现...
HTML
<div id="topnav">
<ul>
<li>
<a href="#">Artist</a>
<ul class="submenu">
<li><a href="#">Sketchbook</a></li>
<li><a href="#">Words</a></li>
<li><a href="#">Media</a></li>
<li><a href="#">Artwork</a></li>
</ul>
</li>
<li><a href="#">UI/UX Developer</a>
<ul class="submenu">
<li><a href="#">Portfolio</a></li>
<li><a href="#">Resume</a></li>
</ul>
</li>
</ul>
</div>
</body>
CSS
<style type="text/css">
h1 { position: absolute;
top: 130%;
left: 50%;
width: 500px;
height: 500px;
margin-top: -250px; /*half the height */
margin-left: -250px; /*half the width */
font-variant: small-caps;
text-align: center;
color:#737b83; }
</style>
<style type="text/css">
a:link { color:#737b83;
font-variant: small-caps;
text-decoration: none;
}
a:visited { font-variant: small-caps;
color: #3f6317;
text-decoration: none;
}
a:hover { font-variant: small-caps;
color: #103b50;
text-decoration: none;
}
a:active { font-variant: small-caps;
color: #44aadd;
text-decoration: none;
}
</style>
<style type="text/css">
p {position: absolute;
left: 85%;
color:#737b83;
font-variant: small-caps;
}
</style>
<style type="text/css">
#topnav
{
float: left;
width: 900px;
height: 24px;
margin-top: 3px;
position: relative;
font-size: 12px;
}
#topnav ul
{
list-style: none;
padding: 0;
margin: 0;
}
#topnav ul li
{
float: left;
margin: 0;
padding: 0;
}
#topnav ul li a
{
padding: 5px 15px;
text-decoration: none;
display: block;
font-weight: bold;
}
#topnav ul li a:link
{
text-decoration: none;
}
#topnav ul li a:visited
{
text-decoration: none;
}
#topnav ul li a.active
{
text-decoration: none;
}
#topnav ul li ul.submenu
{ float: left;
position: absolute;
left: 0;
top: 24px;
display: none;
}
#topnav ul li ul.submenu a
{
display: inline;
}
#topnav ul li ul.submenu li:last-child
{
border-right-style: none;
}
</style>
JavaScript
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js">
var ddmenuitem = 0;
function jsddm_open()
{ jsddm_close();
ddmenuitem =
$(this).find('ul.submenu').css('display', 'block');
}
function jsddm_close()
{
if(ddmenuitem) ddmenuitem.css('display','none');
}
$(document).ready(function()
{
$('#topnav > ul > li ').bind('click', jsddm_open)
$('#topnav > ul > li > a').click(function(){
if ($(this).attr('class') !='active')
{
$('#topnav ul li a').removeClass('active');
}
});
});
</script>
<script language="javascript">
var ddmenuitem = 0;
function jsddm_open()
{ jsddm_close();
ddmenuitem =
$(this).find('ul.submenu').css('display', 'block');
}
function jsddm_close()
{
if(ddmenuitem) ddmenuitem.css('display','none');
}
$(document).ready(function()
{
$('#topnav > ul > li ').bind('click', jsddm_open)
$('#topnav > ul > li > a').click(function(){
if ($(this).attr('class') !='active')
{
$('#topnav ul li a').removeClass('active');
}
});
});
</script>
有人可以解释为什么它没有显示吗?