当前位置:首页 >> 网络编程

JQuery实现折叠式菜单的详细代码

两种风格:

1:点菜单项,每个子菜单项都可显示

JQuery实现折叠式菜单的详细代码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>30秦甜甜_实训13-2_2_180701802230_18计算机2班</title>
	</head>
	<style type="text/css">
		* {
			padding: 0;
			margin: 0;
			list-style: none;
		}

		.menu-list {
			width: 300px;
			margin: 60px auto;
			border: 2px solid #bbffff;
		}

		.menu-head {
			background-color: #aaaaff;
			text-align: center;
			height: 100px;
			line-height: 100px;
		}

		.menu-body>li {
			height: 60px;
			line-height: 60px;
			text-align: center;
		}
	</style>
	<script src="/UploadFiles/2021-04-02/jquery.js">

运行结果图:

JQuery实现折叠式菜单的详细代码

2:点菜单项,仅当前子菜单项可显示,其余子菜单隐藏

JQuery实现折叠式菜单的详细代码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>30秦甜甜_实训13-2_3_180701802230_18计算机2班</title>
	</head>
	<style type="text/css">
		* {
			padding: 0;
			margin: 0;
			list-style: none;
		}

		.menu-list {
			width: 300px;
			margin: 60px auto;
			border: 2px solid #bbffff;
		}

		.menu-head {
			background-color: #aaaaff;
			text-align: center;
			height: 100px;
			line-height: 100px;
		}

		.menu-body>li {
			height: 60px;
			line-height: 60px;
			text-align: center;
		}
	</style>
	<script src="/UploadFiles/2021-04-02/jquery.js">

运行结果图:

JQuery实现折叠式菜单的详细代码

总结