以下是一个简化的HTML代码示例,展示了如何使用Bootstrap和jQuery来创建一个响应式的美食文化网站的头部导航栏。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>美食文化</title>
<!-- 引入Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<style>
/* 自定义样式 */
.navbar-custom {
background-color: #ffc107; /* 金色背景 */
margin-bottom: 0; /* 移除默认的底部边距 */
}
.navbar-custom .navbar-nav li {
margin-left: 5px; /* 增加左边距以分隔导航项 */
margin-right: 5px; /* 增加右边距以分隔导航项 */
}
.navbar-custom .navbar-nav li a {
color: #333; /* 导航链接颜色 */
}
.navbar-custom .navbar-nav li a:hover {
color: #fff; /* 鼠标悬浮时的颜色 */
}
</style>
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-custom">
<div class="container">
<a class="navbar-brand" href="#">美食文化</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">首页 <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">美食文化</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">美食评论</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">美食博客</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">关于我们</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- 引入jQuery,Popper.js和Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnj