<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Navigation Menu</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
}
.nav-bar {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #007bff;
padding: 10px 20px;
color: white;
}
.nav-bar h1 {
margin: 0;
}
.nav-links {
display: flex;
gap: 15px;
}
.nav-links a {
color: white;
text-decoration: none;
font-size: 1em;
}
.nav-links a:hover {
text-decoration: underline;
}
.menu-toggle {
display: none;
flex-direction: column;
cursor: pointer;
}
.menu-toggle div {
width: 25px;
height: 3px;
background-color: white;
margin: 3px 0;
}
.nav-menu {
display: flex;
}
@media (max-width: 768px) {
.nav-links {
display: none;
flex-direction: column;
width: 100%;
position: absolute;
top: 50px;
left: 0;
background-color: #007bff;
z-index: 1;
}
.nav-links.active {
display: flex;
}
.menu-toggle {
display: flex;
}
}
</style>
</head>
<body>
<header class="nav-bar">
<h1>My Website</h1>
<div class="menu-toggle" onclick="toggleMenu()">
<div></div>
<div></div>
<div></div>
</div>
<nav class="nav-links">
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Contact</a>
</nav>
</header>
<script>
function toggleMenu() {
const navLinks = document.querySelector('.nav-links');
navLinks.classList.toggle('active');
}
</script>
</body>
</html>
响应式导航菜单
原创mb64cc5144d532c ©著作权
文章标签 html Responsive 文章分类 软件研发
下一篇:响应式表单布局
-
响应式开发(一)-----响应式网页设计学习导航
什么是响应式web设计现在开发
响应式 网页设计 响应式web设计 响应式设计 前端框架 -
bootstrap-响应式导航条
bootstrap-响应式导航条
bootstrap 导航条 响应式 -
响应式面包屑菜单
在线演示 本地下载
响应式面包屑菜单 it技术 -
滑出式网页导航菜单
滑出式网页导航菜单
sed 子菜单 html