构建一个导航栏web

html 复制代码
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			*{
				margin: 0;
				padding: 0;
			}
			#menu{
				background-color:purple;
				width: 100px;
				height: 50px;
			}
			.item{
				float: left;
				/* 浮动标签可以让块标签,处于同一行 */
				width: 100px;
				height: 50px;
				line-height: 50px;
				text-align: center;
				color: white;
				position: relative;
			}
			.item:hover{
				background-color: red;
			}
			#container{
				width: 720px;
				margin: auto;
			}
			.down>div{
				color:black;
			}
			.down{
				background-color:#ccc;
				display: none;
				position: absolute;
			}
			.item:hover>.down{
				display: block;
				width:100px;
				top: 50px;
				left: 0px;
			}
		</style>
	</head>
	<body>
		<div id="menu">
			<div id="container">
				<div class="item">游戏1
				<div class="down">
					<!-- 要是需要多个就不能用id,id只能用一次,复制多个得用class -->
					<div>下载</div>
					<div>交易</div>
					<div>外挂</div>
					<div>攻略</div>
				</div>
				</div>
				<div class="item">游戏2
				 <div class="down">
					<!-- 要是需要多个就不能用id,id只能用一次,复制多个得用class -->
					<div>下载</div>
					<div>交易</div>
					<div>外挂</div>
					<div>攻略</div>
				 </div>
				</div>
				<div class="item">游戏3
				<div class="down">
					<!-- 要是需要多个就不能用id,id只能用一次,复制多个得用class -->
					<div>下载</div>
					<div>交易</div>
					<div>外挂</div>
					<div>攻略</div>
				</div>
				</div>
				<div class="item">游戏4
				<div class="down">
					<!-- 要是需要多个就不能用id,id只能用一次,复制多个得用class -->
					<div>下载</div>
					<div>交易</div>
					<div>外挂</div>
					<div>攻略</div>
				</div>
				</div>
				<div class="item">游戏5
				<div class="down">
					<!-- 要是需要多个就不能用id,id只能用一次,复制多个得用class -->
					<div>下载</div>
					<div>交易</div>
					<div>外挂</div>
					<div>攻略</div>
				</div>
				</div>
				<div class="item">游戏6
				<div class="down">
					<!-- 要是需要多个就不能用id,id只能用一次,复制多个得用class -->
					<div>下载</div>
					<div>交易</div>
					<div>外挂</div>
					<div>攻略</div>
				</div>
				</div>
				<div class="item">游戏7
				<div class="down">
					<!-- 要是需要多个就不能用id,id只能用一次,复制多个得用class -->
					<div>下载</div>
					<div>交易</div>
					<div>外挂</div>
					<div>攻略</div>
				 </div>
				</div>
			<div class="item">游戏2</div>
			<div class="item">游戏3</div>
			<div class="item">游戏4</div>
			<div class="item">游戏5</div>
			<div class="item">游戏6</div>
			<div class="item">游戏7</div>
		</div>
		</div>
	</body>
</html>

代码如上;

代码实现效果如下所示:

相关推荐
DanCheng-studio2 分钟前
毕设 基于机器视觉的驾驶疲劳检测系统(源码+论文)
python·毕业设计·毕设
carpell4 分钟前
【语义分割专栏】3:Segnet实战篇(附上完整可运行的代码pytorch)
人工智能·python·深度学习·计算机视觉·语义分割
晓得迷路了7 分钟前
栗子前端技术周刊第 84 期 - Vite v7.0 beta、Vitest 3.2、Astro 5.9...
前端·javascript·vite
独立开阀者_FwtCoder10 分钟前
最全301/302重定向指南:从SEO到实战,一篇就够了
前端·javascript·vue.js
Moment19 分钟前
给大家推荐一个超好用的 Marsview 低代码平台 🤩🤩🤩
前端·javascript·github
小满zs23 分钟前
Zustand 第三章(状态简化)
前端·react.js
普宁彭于晏24 分钟前
元素水平垂直居中的方法
前端·css·笔记·css3
恋猫de小郭36 分钟前
为什么跨平台框架可以适配鸿蒙,它们的技术原理是什么?
android·前端·flutter
云浪39 分钟前
元素变形记:CSS 缩放函数全指南
前端·css
一只小波波呀1 小时前
打卡第48天
python