博客列表 >淘宝移动端首页商品列表实例

淘宝移动端首页商品列表实例

天宁
天宁原创
2022年04月02日 19:24:52361浏览

html部分代码

  1. <!-- 2. 商品列表 -->
  2. <div class="list">
  3. <div class="recommend-hd-bg">
  4. <img src="https://img.alicdn.com/tfs/TB1V2eQrKSSBuNjy0FlXXbBpVXa-966-114.png" />
  5. </div>
  6. <div class="goods">
  7. <div class="goods-list">
  8. <a href="">
  9. <img src="images/goods/1.jpg" alt="" />
  10. <span>包邮日本制进口野田珐琅Pochka搪瓷双耳</span>
  11. <div class="price">
  12. <span>¥ 12585.9</span>
  13. <span>100+人已购买</span>
  14. </div>
  15. </a>
  16. </div>
  17. <div class="goods-list">
  18. <a href="">
  19. <img src="images/goods/2.jpg" alt="" />
  20. <span>蕾丝加厚马桶垫夏季网红马桶坐垫大号坐便</span>
  21. <div class="price">
  22. <span>¥ 32.9</span>
  23. <span>100+人已购买</span>
  24. </div>
  25. </a>
  26. </div>
  27. <div class="goods-list">
  28. <a href="">
  29. <img src="images/goods/1.jpg" alt="" />
  30. <span>包邮日本制进口野田珐琅Pochka搪瓷双耳</span>
  31. <div class="price">
  32. <span>¥ 12.9</span>
  33. <span>100+人已购买</span>
  34. </div>
  35. </a>
  36. </div>
  37. <div class="goods-list">
  38. <a href="">
  39. <img src="images/goods/1.jpg" alt="" />
  40. <span>包邮日本制进口野田珐琅Pochka搪瓷双耳</span>
  41. <div class="price">
  42. <span>¥ 12.9</span>
  43. <span>100+人已购买</span>
  44. </div>
  45. </a>
  46. </div>
  47. <div class="goods-list">
  48. <a href="">
  49. <img src="images/goods/1.jpg" alt="" />
  50. <span>包邮日本制进口野田珐琅Pochka搪瓷双耳</span>
  51. <div class="price">
  52. <span>¥ 12.9</span>
  53. <span>100+人已购买</span>
  54. </div>
  55. </a>
  56. </div>
  57. <div class="goods-list">
  58. <a href="">
  59. <img src="images/goods/1.jpg" alt="" />
  60. <span>包邮日本制进口野田珐琅Pochka搪瓷双耳</span>
  61. <div class="price">
  62. <span>¥ 12.9</span>
  63. <span>100+人已购买</span>
  64. </div>
  65. </a>
  66. </div>
  67. </div>
  68. </div>

css代码

  1. /* 你可能还喜欢 */
  2. main .list .recommend-hd-bg {
  3. width: 100%;
  4. height: 0.47rem;
  5. display: flex;
  6. justify-content: center;
  7. align-items: center;
  8. }
  9. /* 设置你可能还喜欢图片宽高 */
  10. main .list .recommend-hd-bg img {
  11. width: 45%;
  12. height: 40%;
  13. }
  14. /* 商品列表 */
  15. main .list .goods {
  16. display: grid;
  17. grid-template-columns: repeat(2, 1fr);
  18. gap: 0.1rem;
  19. }
  20. /* 设置单个商品的grid */
  21. main .list .goods .goods-list a {
  22. display: grid;
  23. height: 2.6rem;
  24. background-color: #fff;
  25. grid-template-columns: repeat(2, 1fr);
  26. grid-template-rows: 6fr 2fr 1fr;
  27. border-radius: 0.1rem;
  28. }
  29. /* 图片跨两列 左右上角加上圆角 */
  30. main .list .goods .goods-list a img {
  31. grid-column: span 2;
  32. border-top-left-radius: 0.1rem;
  33. border-top-right-radius: 0.1rem;
  34. }
  35. /* 商品标题跨两列 加一个呼吸距离 */
  36. main .list .goods .goods-list a > span:first-of-type {
  37. grid-column: span 2;
  38. padding: 0.1rem;
  39. }
  40. /* 价格和购买人次 */
  41. main .list .goods .goods-list .price {
  42. grid-column: span 2;
  43. display: flex;
  44. padding: 0.05rem 0.1rem;
  45. }
  46. /* 价格和购买人次之间距离 */
  47. main .list .goods .goods-list .price span:first-of-type {
  48. padding-right: 0.1rem;
  49. color: #ff5500;
  50. }
  51. main .list .goods .goods-list .price span:last-of-type {
  52. color: #999999;
  53. }
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议