帮我生成一个商品列表,里面有对应的商品名称 还有商品图片 商品原价,商品秒杀价,库存数量等字段。请给我写一个用css美化过后的html页面
时间: 2024-05-28 18:12:14 浏览: 73
美化商品列表页面.docx
好的,以下是一个简单的商品列表的HTML和CSS代码,你可以根据实际情况修改和优化它:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>商品列表</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
margin: 0;
padding: 0;
}
h1 {
text-align: center;
color: #333;
margin-top: 30px;
}
.container {
max-width: 900px;
margin: 0 auto;
padding: 20px;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.card {
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
background-color: #fff;
margin-bottom: 30px;
width: calc(33.33% - 20px);
padding: 20px;
box-sizing: border-box;
transition: all 0.3s ease-in-out;
}
.card:hover {
box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
transform: translateY(-5px);
}
.card img {
max-width: 100%;
height: auto;
margin-bottom: 10px;
}
.card h3 {
font-size: 20px;
color: #333;
margin: 0;
margin-bottom: 10px;
}
.card .price {
font-size: 16px;
color: #999;
margin: 0;
margin-bottom: 20px;
text-decoration: line-through;
}
.card .seckill-price {
font-size: 24px;
color: #f00;
margin: 0;
margin-bottom: 20px;
}
.card .stock {
font-size: 14px;
color: #999;
margin: 0;
margin-top: 10px;
}
@media screen and (max-width: 767px) {
.card {
width: calc(50% - 20px);
}
}
@media screen and (max-width: 480px) {
.card {
width: calc(100% - 20px);
}
}
</style>
</head>
<body>
<h1>商品列表</h1>
<div class="container">
<div class="card">
<img src="https://via.placeholder.com/300x200.png" alt="商品图片">
<h3>商品名称</h3>
<p class="price">原价:$99.99</p>
<p class="seckill-price">秒杀价:$49.99</p>
<p class="stock">库存:100</p>
</div>
<div class="card">
<img src="https://via.placeholder.com/300x200.png" alt="商品图片">
<h3>商品名称</h3>
<p class="price">原价:$99.99</p>
<p class="seckill-price">秒杀价:$49.99</p>
<p class="stock">库存:100</p>
</div>
<div class="card">
<img src="https://via.placeholder.com/300x200.png" alt="商品图片">
<h3>商品名称</h3>
<p class="price">原价:$99.99</p>
<p class="seckill-price">秒杀价:$49.99</p>
<p class="stock">库存:100</p>
</div>
<div class="card">
<img src="https://via.placeholder.com/300x200.png" alt="商品图片">
<h3>商品名称</h3>
<p class="price">原价:$99.99</p>
<p class="seckill-price">秒杀价:$49.99</p>
<p class="stock">库存:100</p>
</div>
<div class="card">
<img src="https://via.placeholder.com/300x200.png" alt="商品图片">
<h3>商品名称</h3>
<p class="price">原价:$99.99</p>
<p class="seckill-price">秒杀价:$49.99</p>
<p class="stock">库存:100</p>
</div>
<div class="card">
<img src="https://via.placeholder.com/300x200.png" alt="商品图片">
<h3>商品名称</h3>
<p class="price">原价:$99.99</p>
<p class="seckill-price">秒杀价:$49.99</p>
<p class="stock">库存:100</p>
</div>
<div class="card">
<img src="https://via.placeholder.com/300x200.png" alt="商品图片">
<h3>商品名称</h3>
<p class="price">原价:$99.99</p>
<p class="seckill-price">秒杀价:$49.99</p>
<p class="stock">库存:100</p>
</div>
<div class="card">
<img src="https://via.placeholder.com/300x200.png" alt="商品图片">
<h3>商品名称</h3>
<p class="price">原价:$99.99</p>
<p class="seckill-price">秒杀价:$49.99</p>
<p class="stock">库存:100</p>
</div>
</div>
</body>
</html>
```
这个商品列表使用了Flex布局来实现响应式布局。每个商品卡片都有一个图片、商品名称、商品原价、商品秒杀价和库存数量等字段。CSS样式使用了阴影、过渡效果和颜色等属性来美化商品列表。
阅读全文