PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

博客列表 > 淘宝首页flex仿写

淘宝首页flex仿写

月光下,遗忘黑暗
月光下,遗忘黑暗 原创
2021年03月29日 20:26:12 704浏览

淘宝首页效果图

html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <link rel="stylesheet" href="static/image/header/font_2449243_u7g1gxzso2q/iconfont.css">
  7. <link rel="stylesheet" href="static/css/header.css">
  8. <link rel="stylesheet" href="static/css/footer.css">
  9. <link rel="stylesheet" href="static/css/main.css">
  10. </head>
  11. <body>
  12. <div class="header">
  13. <div class="iconfont icon-shejiaotubiao-08"></div>
  14. <div class="search" >
  15. <div class="img">
  16. <img src="static/image/header/搜索.png" alt="">
  17. </div>
  18. <input type="text" class="words" value="寻找宝贝店铺">
  19. </div>
  20. </div>
  21. <div class="main">
  22. <ul class="nav">
  23. <li>
  24. <a href=""><img src="static/image/dh/1.png" alt=""></a>
  25. <a href="">天猫新品</a>
  26. </li>
  27. <li>
  28. <a href=""><img src="static/image/dh/2.png" alt=""></a>
  29. <a href="">今日爆款</a>
  30. </li>
  31. <li>
  32. <a href=""><img src="static/image/dh/3.png" alt=""></a>
  33. <a href="">天猫国际</a>
  34. </li>
  35. <li>
  36. <a href=""><img src="static/image/dh/4.png" alt=""></a>
  37. <a href="">饿了么</a>
  38. </li>
  39. <li>
  40. <a href=""><img src="static/image/dh/5.png" alt=""></a>
  41. <a href="">天猫超市</a>
  42. </li>
  43. <li>
  44. <a href=""><img src="static/image/dh/6.png" alt=""></a>
  45. <a href="">充值中心</a>
  46. </li>
  47. <li>
  48. <a href=""><img src="static/image/dh/7.png" alt=""></a>
  49. <a href="">机票酒店</a>
  50. </li>
  51. <li>
  52. <a href=""><img src="static/image/dh/8.png" alt=""></a>
  53. <a href="">金币庄园</a>
  54. </li>
  55. <li>
  56. <a href=""><img src="static/image/dh/9.png" alt=""></a>
  57. <a href="">阿里拍卖</a>
  58. </li>
  59. <li>
  60. <a href=""><img src="static/image/dh/10.png" alt=""></a>
  61. <a href="">淘宝吃货</a>
  62. </li>
  63. </ul>
  64. <ul class="shop">
  65. <li>
  66. <div> <a href=""><img src="//gw.alicdn.com/bao/uploaded/i1/51890164/O1CN0157MFrP1D59ZeJm7Yt_!!51890164-0-lubanu-s.jpg_500x500q90.jpg_.webp" alt=""></a></div>
  67. <p href="">商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍</p>
  68. <div class="price">
  69. <div class="iconfont icon-jiage">138.00</div>
  70. <div class="people">100人已购买</div>
  71. </div>
  72. </li>
  73. <li>
  74. <div> <a href=""><img src="//gw.alicdn.com/bao/uploaded/i1/51890164/O1CN0157MFrP1D59ZeJm7Yt_!!51890164-0-lubanu-s.jpg_500x500q90.jpg_.webp" alt=""></a></div>
  75. <p href="">商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍</p>
  76. <div class="price">
  77. <div class="iconfont icon-jiage">138.00</div>
  78. <div class="people">100人已购买</div>
  79. </div>
  80. </li>
  81. <li>
  82. <div> <a href=""><img src="//gw.alicdn.com/bao/uploaded/i1/51890164/O1CN0157MFrP1D59ZeJm7Yt_!!51890164-0-lubanu-s.jpg_500x500q90.jpg_.webp" alt=""></a></div>
  83. <p href="">商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍</p>
  84. <div class="price">
  85. <div class="iconfont icon-jiage">138.00</div>
  86. <div class="people">100人已购买</div>
  87. </div>
  88. </li>
  89. <li>
  90. <div> <a href=""><img src="//gw.alicdn.com/bao/uploaded/i1/51890164/O1CN0157MFrP1D59ZeJm7Yt_!!51890164-0-lubanu-s.jpg_500x500q90.jpg_.webp" alt=""></a></div>
  91. <p href="">商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍</p>
  92. <div class="price">
  93. <div class="iconfont icon-jiage">138.00</div>
  94. <div class="people">100人已购买</div>
  95. </div>
  96. </li>
  97. </ul>
  98. </div>
  99. <div class="footer">
  100. <div>
  101. <div class="iconfont icon-rhome-fill"></div>
  102. <span>首页</span>
  103. </div>
  104. <div>
  105. <div class="iconfont icon-rhome-fill"></div>
  106. <span>购物车</span>
  107. </div>
  108. <div>
  109. <div class="iconfont icon-rhome-fill"></div>
  110. <span>订单列表</span>
  111. </div>
  112. <div>
  113. <div class="iconfont icon-rhome-fill"></div>
  114. <span>我的淘宝</span>
  115. </div>
  116. <div>
  117. <div class="iconfont icon-rhome-fill"></div>
  118. <span>更多</span>
  119. </div>
  120. </div>
  121. </body>
  122. </html>

css代码

header部分

  1. @import "reset.css";
  2. .header {
  3. /*转为flex容器*/
  4. display: flex;
  5. /*默认主轴水平*/
  6. flex-flow: row nowrap;
  7. /*垂直方向的对齐方式*/
  8. align-items: center;
  9. background-color: rgb(255,133,42);
  10. color: #F6F6F6;
  11. height: 10rem;
  12. /*固定定位*/
  13. position: fixed;
  14. left: 0;
  15. top: 0;
  16. right: 0;
  17. /*内容放在视口最前端*/
  18. z-index: 100;
  19. }
  20. .header .iconfont {
  21. text-align: center;
  22. flex: 1;
  23. font-size: 7rem;
  24. }
  25. .header .search {
  26. background-color: rgb(255,78,34);
  27. flex: 7;
  28. padding: 0.5rem;
  29. border-radius: 1rem;
  30. /*弹性布局*/
  31. display: flex;
  32. text-align: center;
  33. }
  34. .search .img{
  35. width: 5rem;
  36. margin-left: 20rem;
  37. }
  38. img {
  39. width: 100%;
  40. }
  41. .search .words {
  42. background-color: rgb(255,78,34);
  43. color: white;
  44. font-size: 4rem;
  45. border:none;
  46. border-radius: 1rem;
  47. /*轮廓线*/
  48. outline: none;
  49. }
  50. .main {
  51. position: absolute;
  52. top: 10rem;
  53. left: 0;
  54. right: 0;
  55. bottom: 10rem;
  56. }
  57. .footer {
  58. height: 10rem;
  59. /*固定定位*/
  60. position: fixed;
  61. left: 0;
  62. bottom: 0;
  63. right: 0;
  64. /*内容放在视口最前端*/
  65. z-index: 100;
  66. }

main部分

  1. .main .nav img {
  2. height: 12rem;
  3. width: 12rem;
  4. }
  5. .main .nav{
  6. display: flex;
  7. /*转为多行容器*/
  8. flex-flow: row wrap;
  9. padding: 0.5rem;
  10. font-size: 2rem;
  11. }
  12. .main .nav li {
  13. /*允许放大*/
  14. /*flex-grow: 1;*/
  15. /*flex-shrink: 1;*/
  16. /*flex-basis: 20%;*/
  17. flex: 1 1 20%;
  18. /*转为flex容器*/
  19. display: flex;
  20. /*垂直排列,禁止换行*/
  21. flex-flow: column nowrap;
  22. /*交叉轴居中*/
  23. align-items: center;
  24. }
  25. .main .shop {
  26. display: flex;
  27. color: #555;
  28. /*转为多行容器,并允许换行*/
  29. flex-flow: row wrap;
  30. justify-content: center;
  31. padding: 0.5rem;
  32. font-size: 2rem;
  33. }
  34. .main .shop li {
  35. flex: 1 1 50%;
  36. padding: 1rem;
  37. }
  38. .shop li img {
  39. width: 100%;
  40. height: 100%;
  41. border-radius: 1.5rem;
  42. }
  43. .shop .iconfont {
  44. color: red;
  45. font-size: 3rem;
  46. }
  47. .price {
  48. padding: 2rem;
  49. display: flex;
  50. }
  51. .people {
  52. color: #969896;
  53. padding-left: 3rem;
  54. padding-top: 0.5rem;
  55. }
  1. .footer {
  2. display: flex;
  3. background-color: white;
  4. justify-content: space-around;
  5. align-items: center;
  6. color: #969896;
  7. height: 10rem;
  8. /*固定定位*/
  9. position: fixed;
  10. left: 0;
  11. bottom: 0;
  12. right: 0;
  13. /*内容放在视口最前端*/
  14. z-index: 100;
  15. }
  16. .footer>div {
  17. display: flex;
  18. /*主轴垂直*/
  19. flex-flow: column nowrap;
  20. /*交叉轴水平居中*/
  21. align-items: center;
  22. }
  23. .footer .iconfont {
  24. font-size: 5rem;
  25. }
  26. .footer div>span {
  27. font-size: 2.5rem;
  28. }
  29. .footer>div {
  30. cursor: pointer;
  31. }
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议