设计一个网页,主页面有滚动播放,然后有4个二级页面的部分展示内容的代码
时间: 2024-03-09 13:50:06 浏览: 134
List View二级页面跳转
以下是一个简单的网页设计示例,包含主页面和4个二级页面的部分展示内容。这里使用了Bootstrap框架和swiper.js插件实现轮播图和卡片式布局。
index.html(主页面):
```
<!DOCTYPE html>
<html>
<head>
<title>网站名称</title>
<!-- 引入Bootstrap和swiper的CSS文件 -->
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/css/swiper.min.css">
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<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">
<li class="nav-item active">
<a class="nav-link" href="#">首页</a>
</li>
<li class="nav-item">
<a class="nav-link" href="page1.html">二级页面1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="page2.html">二级页面2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="page3.html">二级页面3</a>
</li>
<li class="nav-item">
<a class="nav-link" href="page4.html">二级页面4</a>
</li>
</ul>
</div>
</nav>
<!-- 轮播图 -->
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide"><img src="img/slide1.jpg"></div>
<div class="swiper-slide"><img src="img/slide2.jpg"></div>
<div class="swiper-slide"><img src="img/slide3.jpg"></div>
<div class="swiper-slide"><img src="img/slide4.jpg"></div>
</div>
<div class="swiper-pagination"></div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
<!-- 引入jQuery、popper.js和Bootstrap的JS文件 -->
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.slim.min.js"></script>
<script src="https://cdn.bootcss.com/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<!-- 引入swiper的JS文件 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/js/swiper.min.js"></script>
<!-- 初始化swiper -->
<script>
var mySwiper = new Swiper('.swiper-container', {
autoplay: {
delay: 3000,
},
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
</script>
</body>
</html>
```
page1.html、page2.html、page3.html、page4.html(四个二级页面):
```
<!DOCTYPE html>
<html>
<head>
<title>二级页面1</title>
<!-- 引入Bootstrap的CSS文件 -->
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.3.1/css/bootstrap.min.css">
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<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">
<li class="nav-item">
<a class="nav-link" href="index.html">首页</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">二级页面1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="page2.html">二级页面2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="page3.html">二级页面3</a>
</li>
<li class="nav-item">
<a class="nav-link" href="page4.html">二级页面4</a>
</li>
</ul>
</div>
</nav>
<!-- 卡片式布局 -->
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4">
<div class="card">
<img src="img/card1.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">卡片标题1</h5>
<p class="card-text">卡片描述1</p>
<a href="#" class="btn btn-primary">查看详情</a>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4">
<div class="card">
<img src="img/card2.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">卡片标题2</h5>
<p class="card-text">卡片描述2</p>
<a href="#" class="btn btn-primary">查看详情</a>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4">
<div class="card">
<img src="img/card3.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">卡片标题3</h5>
<p class="card-text">卡片描述3</p>
<a href="#" class="btn btn-primary">查看详情</a>
</div>
</div>
</div>
</div>
</div>
<!-- 引入jQuery和Bootstrap的JS文件 -->
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.slim.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</body>
</html>
```
注意:上述代码中的图片和样式文件需要根据实际情况进行替换或下载保存。同时,为了使swiper.js插件正常工作,需要在页面底部引入swiper的JS文件并在页面加载完成后初始化swiper。
阅读全文