参考资料

  1. 如何避免 CSS 过渡动画卡顿?
  2. 颜色属性详细说明以及案例
  3. 有没有现成的Vanta.js与CSS过渡模板?
  4. 哪种布局方式更适合移动端?
  5. css中div居中
  6. CSS格式化/压缩有哪些
  7. 目标伪类选择器详细说明以及案例
  8. css让div居中的几种方法

如何用添加产品图片和描述?

  1. HTML结构

<div class="product">
  <img src="product-image.jpg" alt="Product Image" class="product-image">
  <div class="product-description">
    <h3>产品名称</h3>
    <p>这里是产品描述内容...</p>
  </div>
</div>
  1. CSS样式

.product {
  display: flex;
  max-width: 800px;
  margin: 20px auto;
  padding: 15px;
  border: 1px solid #ddd;
  border-radius: 5px;
}

.product-image {
  width: 300px;
  height: auto;
  margin-right: 20px;
  object-fit: cover;
}

.product-description {
  flex: 1;
}

.product-description h3 {
  color: #333;
  margin-bottom: 10px;
}

.product-description p {
  color: #666;
  line-height: 1.5;
}
  1. 响应式调整

@media (max-width: 600px) {
  .product {
    flex-direction: column;
  }
  
  .product-image {
    width: 100%;
    margin-right: 0;
    margin-bottom: 15px;
  }
}
  1. 可选效果

.product:hover {
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  transition: box-shadow 0.3s ease;
}

.product-image {
  transition: transform 0.3s ease;
}

.product-image:hover {
  transform: scale(1.02);
}