写一个html网页制作,带有图片轮播和链接功能
时间: 2023-12-26 19:23:55 浏览: 138
好的,以下是一个简单的 HTML 网页模板,包含图片轮播和链接功能:
```html
<!DOCTYPE html>
<html>
<head>
<title>图片轮播和链接</title>
<meta charset="UTF-8">
<!-- 引入 jQuery 和 Bootstrap CSS 和 JS -->
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.0/js/bootstrap.min.js"></script>
<!-- 自定义 CSS -->
<style>
.carousel-item img {
height: 300px;
object-fit: cover;
}
</style>
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="#">网页标题</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">首页</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">链接1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">链接2</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- 图片轮播 -->
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://picsum.photos/id/1019/900/300" class="d-block w-100" alt="图片1">
<div class="carousel-caption d-none d-md-block">
<h5>图片1标题</h5>
<p>图片1描述</p>
</div>
</div>
<div class="carousel-item">
<img src="https://picsum.photos/id/1020/900/300" class="d-block w-100" alt="图片2">
<div class="carousel-caption d-none d-md-block">
<h5>图片2标题</h5>
<p>图片2描述</p>
</div>
</div>
<div class="carousel-item">
<img src="https://picsum.photos/id/1021/900/300" class="d-block w-100" alt="图片3">
<div class="carousel-caption d-none d-md-block">
<h5>图片3标题</h5>
<p>图片3描述</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<!-- 链接按钮 -->
<div class="container mt-4">
<div class="row">
<div class="col-sm-6">
<a href="#" class="btn btn-primary btn-lg btn-block">按钮1</a>
</div>
<div class="col-sm-6">
<a href="#" class="btn btn-secondary btn-lg btn-block">按钮2</a>
</div>
</div>
</div>
</body>
</html>
```
上面的代码中,我们使用 Bootstrap 框架来实现图片轮播和链接按钮的样式。其中图片轮播使用了 `carousel` 组件,链接按钮使用了 `btn` 组件。你只需要替换图片链接和按钮链接即可实现自己的需求。
阅读全文