产品列表(Product List)通常是指在电子商务网站或应用程序中展示商品信息的列表。CSS(Cascading Style Sheets)是一种用于描述HTML或XML(包括SVG、MathML等各种XML方言)文档样式的样式表语言。通过CSS,可以控制网页的布局、颜色、字体等视觉效果。
以下是一个简单的静态产品列表的HTML和CSS代码示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Product List</title>
<style>
.product-list {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 20px;
}
.product-item {
width: calc(33.33% - 20px);
border: 1px solid #ccc;
padding: 20px;
box-sizing: border-box;
}
.product-item img {
width: 100%;
height: auto;
}
.product-item h3 {
margin-top: 10px;
font-size: 18px;
}
.product-item p {
margin-top: 5px;
font-size: 14px;
color: #666;
}
</style>
</head>
<body>
<div class="product-list">
<div class="product-item">
<img src="product1.jpg" alt="Product 1">
<h3>Product 1</h3>
<p>$19.99</p>
</div>
<div class="product-item">
<img src="product2.jpg" alt="Product 2">
<h3>Product 2</h3>
<p>$29.99</p>
</div>
<div class="product-item">
<img src="product3.jpg" alt="Product 3">
<h3>Product 3</h3>
<p>$39.99</p>
</div>
</div>
</body>
</html>
<head>
标签内加载。通过以上方法,可以有效解决产品列表在CSS应用中遇到的常见问题。
领取专属 10元无门槛券
手把手带您无忧上云