html | 无js二级菜单

1. 效果图

2. 代码

复制代码
<meta charset="utf-8">

<style>
.hiddentitle{display:none;}

nav ul{
	list-style-type: none;
	background-color: #001f3f;
	overflow:hidden; /* 父标签加这个,防止有浮动子元素时,该标签失去高度*/
	margin: 0;
    padding: 0;

	border-bottom: 1px solid white;
	font-size: 1.6em;
}

ul > li > ul {
    font-size: 1em;
	border:1px solid #bbb;
}

nav li{
	float: left;
	border-right: 1px solid #bbb;
	
}

nav li a{
    display: inline-block; /* display the list items inline block so the items are vertically displayed */
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none; /* removes the underline that comes with the a tag */
}

nav li a:hover{
	background-color: #39CCCC;
}

nav>ul>li>ul{
	display: none;
    position: absolute;
	background-color: #f9f9f9;
	/*
    min-width: 160px;
	z-index: 1;
	*/
}

nav>ul>li>ul li{
	display: block;
	float: none;
    overflow: hidden;
}

nav>ul>li>ul li a { /* styling of the links in the submenu */
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
}

nav>ul>li>ul a:hover {
    background-color: #f1f1f1;
}
nav>ul>li:hover ul {
    display: block;
    float: bottom;
    overflow: hidden;
}
</style>

menu without js, test under chrome.

<nav>
	<h2 class="hiddentitle">Menu</h2>

	<ul>
		<li><a href="#stats0">Summary Statistics</a></li>

		<li>
		  <a href="#plots">Plots2</a>
		  <ul>
			<li><a href="#a1">Weighted histogram of read lengths</a></li>
			<li><a href="#a2">Weighted histogram of read lengths after log transformation</a></li>
			<li><a href="#a3">Non weighted histogram of read lengths</a></li>
			<li><a href="#a4">Non weighted histogram of read lengths after log transformation</a></li>
			<li><a href="#a5">Yield by length</a></li>
		  </ul>
		</li>
		
		<li><a href="#function">Function</a></li>
		<li>
			<a href="#logs">Logs2</a>
		  <ul>
			<li><a href="#b1">logs1</a></li>
			<li><a href="#b2">log2</a></li>
		  </ul>
		
		</li>
	</ul>
	
</nav>

a new line. v2.2
<p>
this is a new line 
this is a new line 
this is a new line 
this is a new line 
this is a new line 
this is a new line 
this is a new line 
</p>
相关推荐
.又是新的一天.2 分钟前
【前端Web开发HTML5+CSS3+移动web视频教程】02 html - 列表、表格、表单
前端·html·html5
程序员鱼皮3 分钟前
你的 IP 归属地,是咋被挖出来的?
前端·后端·计算机·程序员·互联网·编程经验
小酒星小杜5 分钟前
在AI时代,技术人应该每天都要花两小时来构建一个自身的构建系统 - 总结篇
前端·vue.js·人工智能
燕山石头8 分钟前
jeecg统一异常处理根据不同模块返回指定响应信息
前端
PyHaVolask21 分钟前
CSRF跨站请求伪造
android·前端·csrf
程序员海军31 分钟前
我的2025:做项目、跑副业、见人、奔波、搬家、维权、再回上海
前端·程序员·年终总结
我来整一篇35 分钟前
[Razor] ASP.NET Core MVC 前端组件快速使用总结
前端·asp.net·mvc
2501_9481226340 分钟前
React Native for OpenHarmony 实战:Steam 资讯 App 隐私政策实现
javascript·react native·react.js·游戏·ecmascript·harmonyos
2501_9481226344 分钟前
React Native for OpenHarmony 实战:Steam 资讯 App 主题设置实现
javascript·react native·react.js·游戏·ecmascript·harmonyos
P7Dreamer1 小时前
微信小程序处理Range分片视频播放问题:前端调试全记录
前端·微信小程序