利用JavaScript+CSS+DIV实现下拉菜单源代码

课堂作业:利用JavaScript+CSS+DIV实现下拉菜单


源代码


<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>菜单演示</title>
		<style type="text/css">
			#con {
				width: 800px;
				height: 400px;
				margin: 100px auto;
				background-color: yellow;
			}
			
			#con ul li {
				float: left;
				width: 150px;
				height: 30px;
				line-height: 30px;
				text-decoration: none;
				text-align: left;
			}
			
			#con a{
				text-decoration: none;
				color: #FFF;
				display: block;
				width: 150px;
				height: 30px;
				background: #666;
			}
			#con a:hover{
				background: pink;
			}
			#con ul ul{
				display: none
			}
			.header{
				text-align: center;
			}
			*{
				margin: 0;
				padding: 0;
				list-style: none;
				font-size:13px;
			}
		</style>
		
	</head>

	<body>
		<div id="con">
			<ul>
				<li id="li01">
					<a href="javascript:;" class="header">平面设计</a>
					<ul id="ul01">
						<li>
							<a href="javascript:;">&nbsp;&nbsp;CorelDRAW</a>
						</li>
						<li>
							<a href="javascript:;">&nbsp;&nbsp;Photoshop</a>
						</li>
						<li>
							<a href="javascript:;">&nbsp;&nbsp;Illustrator</a>
						</li>
						<li>
							<a href="javascript:;">&nbsp;&nbsp;Sketch</a>
						</li>
					</ul>
				</li>

				<li id="li02">
					<a href="javascript:;" class="header">网页设计</a>
					<ul id="ul02">
						<li>
							<a href="javascript:;">&nbsp;&nbsp;HTML基础</a>
						</li>
						<li>
							<a href="javascript:;">&nbsp;&nbsp;CSS层叠样式表</a>
						</li>
						<li>
							<a href="javascript:;">&nbsp;&nbsp;JavaScript</a>
						</li>
						<li>
							<a href="javascript:;">&nbsp;&nbsp;Dreamweaver</a>
						</li>
					</ul>
				</li>
				<li id="li03">
					<a href="javascript:;" class="header">影视动画</a>
					<ul id="ul03">
						<li>
							<a href="javascript:;">&nbsp;&nbsp;AF入门到精通</a>
						</li>
						<li>
							<a href="javascript:;">&nbsp;&nbsp;Premiere进阶</a>
						</li>
						<li>
							<a href="javascript:;">&nbsp;&nbsp;Edius基础到提高</a>
						</li>
						<li>
							<a href="javascript:;">&nbsp;&nbsp;ZBrush基础</a>
						</li>
					</ul>
				</li>
				<li id="li04">
					<a href="javascript:;" class="header">室内设计</a>
					<ul id="ul04">
						<li>
							<a href="javascript:;">&nbsp;&nbsp;3ds Max入门</a>
						</li>
						<li>
							<a href="javascript:;">&nbsp;&nbsp;别墅施工图现场</a>
						</li>
						<li>
							<a href="javascript:;">&nbsp;&nbsp;VR室内效果图基础</a>
						</li>
						<li>
							<a href="javascript:;">&nbsp;&nbsp;SU建模及3D渲染</a>
						</li>
					</ul>
				</li>
			</ul>
		</div>
	</body>

</html>

<script type="text/javascript">
			function myfn(param1,param2){
				var myli=document.getElementById(param1);
				var myul=document.getElementById(param2);
				myli.onmouseover=function(){
					myul.style.display='block';
				}
				myli.onmouseout=function(){
					myul.style.display='none';
				}
			}
			myfn('li01','ul01');
			myfn('li02','ul02');
			myfn('li03','ul03');
			myfn('li04','ul04');
		</script>

操作截图
利用JavaScript+CSS+DIV实现下拉菜单源代码
利用JavaScript+CSS+DIV实现下拉菜单源代码
利用JavaScript+CSS+DIV实现下拉菜单源代码
利用JavaScript+CSS+DIV实现下拉菜单源代码

上一篇:怎样在 Linux 中配置静态网络连接[每日前端夜话0x74]


下一篇:基于Linux C上的TCP/IP协议完成的电子点餐系统