CSS带箭头的导航菜单

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery.js"></script>
<title>Menu</title>


<style type="text/css">
ul, li { 
	list-style-type:none; 
	padding:0; 
	margin:0; 
} 

#menu { 
	border:1px solid #dedede; 
	height:35px; 
	background:url(bg_out.gif) repeat-x;
} 

#menu li { 
	float:left; 
	line-height:35px; 
	padding-left: 10px;
	padding-right: 15px;
} 

#menu li div {
	height: 100%;
	width: 100%;
}

.li_out {
	background:url(arrow_out.gif) no-repeat right center;
}

.li_over {
	cursor:hand;
	background:url(arrow_over.gif) no-repeat right center;
	color:white;
}

.div_over {
	background: url(bg_over.gif) repeat-x;
	margin-left: -10px;
	padding-left: 10px;
}
</style>
<script type="text/javascript">
	$(document).ready(function(){
		$("#menu").children("li").hover(
			function(){
				$(this).addClass("li_over");
				$(this).children("div").addClass("div_over");
			},
			function(){
				$(this).removeClass("li_over");
				$(this).children("div").removeClass("div_over");
			}
		);
	});
</script>

</head>

<body>

	<ul id="menu"> 
		<li class="li_out"><div>呵呵</div></li> 
		<li class="li_out"><div>呵呵   File</div></li> 
		<li class="li_out"><div>呵呵   Account</div></li> 
		<li class="li_out"><div>呵呵   呵呵呵呵</div></li> 
		<li class="li_out"><div>呵呵   呵呵呵呵</div></li> 
	</ul>


</body>
</html>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
制作下拉箭头导航栏可以使用HTMLCSSJavaScript来完成。下面是一种常见的实现方式: 1. 首先,在HTML中创建导航栏结构,可以使用无序列表(<ul>)和列表项(<li>)来实现: ``` <nav> <ul> <li><a href="#">Home</a></li> <li> <a href="#">Products</a> <ul> <li><a href="#">Product 1</a></li> <li><a href="#">Product 2</a></li> </ul> </li> <li><a href="#">Contact</a></li> </ul> </nav> ``` 2. 使用CSS来设置导航栏的样式,包括字体、背景颜色、宽度、边框等。同时,为下拉菜单设置隐藏属性,只有在鼠标悬停时才显示出来。可以使用伪类:hover来实现悬停效果: ``` nav { background-color: #333; width: 100%; } nav ul { margin: 0; padding: 0; list-style: none; } nav ul li { float: left; } nav ul li a { display: block; color: #fff; text-align: center; padding: 14px 16px; text-decoration: none; } nav ul li:hover { background-color: #555; } nav ul li ul { display: none; position: absolute; } nav ul li:hover > ul { display: inherit; } nav ul li ul li { float: none; position: relative; } nav ul li ul li a { padding: 10px 20px; color: #fff; background-color: #333; } ``` 3. 最后,使用JavaScript为下拉箭头添加交互效果。当用户点击下拉箭头时,下拉菜单显示出来;再次点击时,下拉菜单隐藏。 ``` var dropdown = document.getElementsByClassName("dropdown-btn"); var i; for (i = 0; i < dropdown.length; i++) { dropdown[i].addEventListener("click", function() { this.classList.toggle("active"); var dropdownContent = this.nextElementSibling; if (dropdownContent.style.display === "block") { dropdownContent.style.display = "none"; } else { dropdownContent.style.display = "block"; } }); } ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值