用bootstrap4写一个旅游主题网页
时间: 2023-07-04 12:17:34 浏览: 102
可以的,以下是一个简单的旅游主题网页的示例代码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Travel Website</title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+J43718WXTFcJl3E9aPjBh/kR0JKIh4" crossorigin="anonymous">
<!-- Custom CSS -->
<link rel="stylesheet" href="style.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Travel Website</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="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Destinations</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact Us</a>
</li>
</ul>
</div>
</nav>
<div class="jumbotron">
<h1 class="display-4">Welcome to our Travel Website</h1>
<p class="lead">Explore the world with us</p>
<hr class="my-4">
<p>Plan your next adventure today</p>
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
</div>
<div class="container">
<h2>Featured Destinations</h2>
<div class="row">
<div class="col-md-4 mb-4">
<div class="card">
<img src="https://picsum.photos/300/200" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Paris, France</h5>
<p class="card-text">Visit the Eiffel Tower and enjoy French cuisine</p>
<a href="#" class="btn btn-primary">Learn more</a>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card">
<img src="https://picsum.photos/300/200" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">New York City, USA</h5>
<p class="card-text">See the Statue of Liberty and explore Central Park</p>
<a href="#" class="btn btn-primary">Learn more</a>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card">
<img src="https://picsum.photos/300/200" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Tokyo, Japan</h5>
<p class="card-text">Experience Japanese culture and cuisine</p>
<a href="#" class="btn btn-primary">Learn more</a>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.3/dist/umd/popper-base.min.js"
integrity="sha384-wzFFcN6yRmWkPv6QlGd4vOc2k8g2E7s8C8Z8T1Tr+QnhBk9t9Rf+oDJjVnS9JwG9"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+J43718WXTFcJl3E9aPjBh/kR0JKIh4" crossorigin="anonymous"></script>
</body>
</html>
```
其中,使用了 Bootstrap 4 的组件和样式,包括 Navbar、Jumbotron、Card 等。CSS 样式文件在 `style.css` 中定义。需要注意的是,这里使用了 CDN 引入了 Bootstrap 和 jQuery 库,而不是下载到本地引入,这样可以加快网页的加载速度。
阅读全文