为我生成一段内嵌CSS的HTML代码,要求如下: -顶部导航栏:基础资料、标准清单、存储方式 -点击顶部导航栏“基础资料”,左侧边导航栏显示“物料信息”、“修程信息” -点击顶部导航栏的“标准清单”,左侧边导航栏显示“梅陇基地”、“蒲汇塘基地” -点击顶部导航栏的“存储方式”,左侧边导航栏显示“全部”、“工具箱”、“挂板货架”、“层板货架”
时间: 2023-08-18 22:03:50 浏览: 94
以下是符合要求的HTML代码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>导航栏示例</title>
<style>
/* 顶部导航栏样式 */
#top-nav {
display: flex;
justify-content: space-around;
background-color: #ccc;
padding: 10px 0;
}
#top-nav a {
color: #333;
text-decoration: none;
font-size: 16px;
}
#top-nav a:hover {
color: #fff;
background-color: #333;
}
/* 左侧边导航栏样式 */
#left-nav {
background-color: #f2f2f2;
padding: 10px;
}
#left-nav ul {
list-style: none;
margin: 0;
padding: 0;
}
#left-nav li {
margin-bottom: 10px;
}
#left-nav a {
color: #333;
text-decoration: none;
font-size: 14px;
}
#left-nav a:hover {
color: #333;
text-decoration: underline;
}
</style>
</head>
<body>
<nav id="top-nav">
<a href="#" class="basic-info">基础资料</a>
<a href="#" class="standard-list">标准清单</a>
<a href="#" class="storage-method">存储方式</a>
</nav>
<div id="left-nav">
<ul class="basic-info-nav">
<li><a href="#">物料信息</a></li>
<li><a href="#">修程信息</a></li>
</ul>
<ul class="standard-list-nav" style="display: none;">
<li><a href="#">梅陇基地</a></li>
<li><a href="#">蒲汇塘基地</a></li>
</ul>
<ul class="storage-method-nav" style="display: none;">
<li><a href="#">全部</a></li>
<li><a href="#">工具箱</a></li>
<li><a href="#">挂板货架</a></li>
<li><a href="#">层板货架</a></li>
</ul>
</div>
<script>
var basicInfoNav = document.querySelector('.basic-info-nav');
var standardListNav = document.querySelector('.standard-list-nav');
var storageMethodNav = document.querySelector('.storage-method-nav');
var basicInfoLink = document.querySelector('.basic-info');
var standardListLink = document.querySelector('.standard-list');
var storageMethodLink = document.querySelector('.storage-method');
basicInfoLink.addEventListener('click', function(e) {
e.preventDefault();
basicInfoNav.style.display = 'block';
standardListNav.style.display = 'none';
storageMethodNav.style.display = 'none';
});
standardListLink.addEventListener('click', function(e) {
e.preventDefault();
basicInfoNav.style.display = 'none';
standardListNav.style.display = 'block';
storageMethodNav.style.display = 'none';
});
storageMethodLink.addEventListener('click', function(e) {
e.preventDefault();
basicInfoNav.style.display = 'none';
standardListNav.style.display = 'none';
storageMethodNav.style.display = 'block';
});
</script>
</body>
</html>
```
阅读全文