用js写一个美妆的“所有商品”页面
时间: 2023-11-22 20:52:10 浏览: 42
好的,以下是一个简单的美妆“所有商品”页面的示例代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>所有商品 - 美妆</title>
<style>
/* 样式表 */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #f9d7e0;
padding: 20px;
text-align: center;
}
h1 {
margin: 0;
font-size: 36px;
}
nav {
background-color: #f1f1f1;
overflow: hidden;
}
nav a {
float: left;
display: block;
color: #333;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
nav a:hover {
background-color: #ddd;
color: black;
}
.product-list {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
padding: 20px;
}
.product-card {
width: calc(33.33% - 10px);
margin-bottom: 20px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
}
.product-card img {
width: 100%;
height: auto;
border-radius: 5px;
}
.product-card h3 {
margin: 10px 0 5px;
font-size: 24px;
}
.product-card p {
margin: 5px 0;
font-size: 16px;
}
.product-card button {
background-color: #f9d7e0;
border: none;
border-radius: 5px;
padding: 10px;
font-size: 16px;
cursor: pointer;
}
.product-card button:hover {
background-color: #eac3cf;
}
</style>
</head>
<body>
<header>
<h1>所有商品 - 美妆</h1>
</header>
<nav>
<a href="#">首页</a>
<a href="#">所有商品</a>
<a href="#">护肤</a>
<a href="#">彩妆</a>
<a href="#">香水</a>
</nav>
<div class="product-list">
<div class="product-card">
<img src="https://via.placeholder.com/300x200" alt="Product 1">
<h3>产品名称</h3>
<p>价格:¥100</p>
<button>加入购物车</button>
</div>
<div class="product-card">
<img src="https://via.placeholder.com/300x200" alt="Product 2">
<h3>产品名称</h3>
<p>价格:¥200</p>
<button>加入购物车</button>
</div>
<div class="product-card">
<img src="https://via.placeholder.com/300x200" alt="Product 3">
<h3>产品名称</h3>
<p>价格:¥300</p>
<button>加入购物车</button>
</div>
<!-- 其他产品卡片 -->
</div>
</body>
</html>
```
这段代码使用了 HTML 和 CSS,没有使用 JavaScript,但你可以添加一些 JavaScript 代码来实现更多的交互功能,如动态加载产品列表、添加到购物车等。