html案例23 商品专栏
时间: 2023-07-01 14:09:18 浏览: 139
以下是一个简单的商品专栏 HTML 案例:
```html
<!DOCTYPE html>
<html>
<head>
<title>商品专栏</title>
<style>
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
margin: 20px;
}
.item {
width: 300px;
height: 400px;
margin: 20px;
padding: 10px;
border: 1px solid #ccc;
box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
text-align: center;
}
.item img {
width: 100%;
height: 250px;
object-fit: cover;
}
.item h2 {
font-size: 24px;
margin-top: 10px;
margin-bottom: 5px;
}
.item p {
font-size: 16px;
margin-top: 5px;
margin-bottom: 10px;
color: #666;
}
.item button {
background-color: #3498db;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease-in-out;
}
.item button:hover {
background-color: #2980b9;
}
</style>
</head>
<body>
<div class="container">
<div class="item">
<img src="https://via.placeholder.com/250x150" alt="Product 1">
<h2>Product 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<button>Add to Cart</button>
</div>
<div class="item">
<img src="https://via.placeholder.com/250x150" alt="Product 2">
<h2>Product 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<button>Add to Cart</button>
</div>
<div class="item">
<img src="https://via.placeholder.com/250x150" alt="Product 3">
<h2>Product 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<button>Add to Cart</button>
</div>
<div class="item">
<img src="https://via.placeholder.com/250x150" alt="Product 4">
<h2>Product 4</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<button>Add to Cart</button>
</div>
<div class="item">
<img src="https://via.placeholder.com/250x150" alt="Product 5">
<h2>Product 5</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<button>Add to Cart</button>
</div>
<div class="item">
<img src="https://via.placeholder.com/250x150" alt="Product 6">
<h2>Product 6</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<button>Add to Cart</button>
</div>
</div>
</body>
</html>
```
在这个案例中,我们使用了 flexbox 布局来创建一个商品专栏。每个商品包含一个图片、标题、描述和一个“添加到购物车”按钮。我们还使用了一些 CSS 样式,如阴影、圆角和过渡效果,来使商品专栏看起来更加漂亮。
阅读全文