使用bootstrap制作一个购物网站的网页。要求使用bootstrap 组件,响应式栅格布局。并且每行代码要有注释
时间: 2024-06-05 22:09:00 浏览: 107
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bootstrap Shopping Website</title>
<!-- 引入Bootstrap样式文件 -->
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css">
<!-- 引入自定义CSS文件 -->
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Shopping 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">
<li class="nav-item active">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Products</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="container-fluid">
<div class="row">
<div class="col-md-3">
<h3>Categories</h3>
<ul class="list-group">
<li class="list-group-item">Clothing</li>
<li class="list-group-item">Shoes</li>
<li class="list-group-item">Accessories</li>
</ul>
</div>
<div class="col-md-9">
<h3>Products</h3>
<div class="row">
<div class="col-md-4">
<div class="card">
<img class="card-img-top" src="https://via.placeholder.com/150" alt="Product Image">
<div class="card-body">
<h5 class="card-title">Product 1</h5>
<p class="card-text">Description of Product 1.</p>
<a href="#" class="btn btn-primary">Buy Now</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<img class="card-img-top" src="https://via.placeholder.com/150" alt="Product Image">
<div class="card-body">
<h5 class="card-title">Product 2</h5>
<p class="card-text">Description of Product 2.</p>
<a href="#" class="btn btn-primary">Buy Now</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<img class="card-img-top" src="https://via.placeholder.com/150" alt="Product Image">
<div class="card-body">
<h5 class="card-title">Product 3</h5>
<p class="card-text">Description of Product 3.</p>
<a href="#" class="btn btn-primary">Buy Now</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 引入jQuery和Bootstrap JS文件 -->
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
注释见代码。
阅读全文