博客列表 >JD布局学习

JD布局学习

▽空城旧梦
▽空城旧梦原创
2021年03月29日 12:39:24610浏览

html代码

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <link rel="stylesheet" href="css/index.css" />
  8. <link rel="stylesheet" href="icon-font/iconfont.css" />
  9. <link rel="stylesheet" href="css/header.css" />
  10. <link rel="stylesheet" href="css/footer.css" />
  11. <link rel="stylesheet" href="css/main.css" />
  12. <title>JD</title>
  13. </head>
  14. <body>
  15. <header>
  16. <div class="iconfont icon-menu"></div>
  17. <div class="search">
  18. <div class="log">JD</div>
  19. <div class="iconfont icon-search"></div>
  20. <input type="text" class="words" value="新疆棉" />
  21. </div>
  22. <a href="" class="login">登入</a>
  23. </header>
  24. <main>
  25. <ul class="nav">
  26. <li>
  27. <a href=""><img src="images/dh/nav-1.png" alt="" /></a>
  28. <a href="">京东超市</a>
  29. </li>
  30. <li>
  31. <a href=""><img src="images/dh/nav-2.png" alt="" /></a>
  32. <a href="">数码电器</a>
  33. </li>
  34. <li>
  35. <a href=""><img src="images/dh/nav-3.png" alt="" /></a>
  36. <a href="">京东服饰</a>
  37. </li>
  38. <li>
  39. <a href=""><img src="images/dh/nav-4.png" alt="" /></a>
  40. <a href="">京东生鲜</a>
  41. </li>
  42. <li>
  43. <a href=""><img src="images/dh/nav-5.png" alt="" /></a>
  44. <a href="">京东到家</a>
  45. </li>
  46. <!-- 第二组 -->
  47. <li>
  48. <a href=""><img src="images/dh/nav-6.png" alt="" /></a>
  49. <a href="">充值缴费</a>
  50. </li>
  51. <li>
  52. <a href=""><img src="images/dh/nav-7.png" alt="" /></a>
  53. <a href="">9.9元拼</a>
  54. </li>
  55. <li>
  56. <a href=""><img src="images/dh/nav-8.png" alt="" /></a>
  57. <a href="">领券</a>
  58. </li>
  59. <li>
  60. <a href=""><img src="images/dh/nav-9.png" alt="" /></a>
  61. <a href="">领金贴</a>
  62. </li>
  63. <li>
  64. <a href=""><img src="images/dh/nav-10.png" alt="" /></a>
  65. <a href="">PLUS会员</a>
  66. </li>
  67. </ul>
  68. <div class="ms">
  69. <!-- 秒杀头部 -->
  70. <div class="ms-top">
  71. <div class="left">
  72. <div class="title">京东秒杀</div>
  73. <div class="notice">
  74. <div class="tips">20点专场</div>
  75. <div class="time">01:40:33</div>
  76. </div>
  77. </div>
  78. <div class="right">更多秒杀</div>
  79. </div>
  80. <!-- 秒杀图片 -->
  81. <ul class="ms-body">
  82. <li class="item">
  83. <a href=""><img src="images/ms/ms-1.jpg" alt="" /></a>
  84. <div class="iconfont icon-rmb">338</div>
  85. <div class="iconfont icon-rmb">558</div>
  86. </li>
  87. <li class="item">
  88. <a href=""><img src="images/ms/ms-2.jpg" alt="" /></a>
  89. <div class="iconfont icon-rmb">3456</div>
  90. <div class="iconfont icon-rmb">4567</div>
  91. </li>
  92. <li class="item">
  93. <a href=""><img src="images/ms/ms-3.jpg" alt="" /></a>
  94. <div class="iconfont icon-rmb">789</div>
  95. <div class="iconfont icon-rmb">999</div>
  96. </li>
  97. <li class="item">
  98. <a href=""><img src="images/ms/ms-4.jpg" alt="" /></a>
  99. <div class="iconfont icon-rmb">3213</div>
  100. <div class="iconfont icon-rmb">4532</div>
  101. </li>
  102. </ul>
  103. </div>
  104. <!-- 推荐 -->
  105. <ul class="tj">
  106. <li class="item">
  107. <a href=""><img src="images/sp/sp-1.webp" alt="" /></a>
  108. <p>
  109. 商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍
  110. </p>
  111. <div class="price">
  112. <div class="iconfont icon-rmb">138</div>
  113. <div>看相似</div>
  114. </div>
  115. </li>
  116. <li class="item">
  117. <a href=""><img src="images/sp/sp-2.webp" alt="" /></a>
  118. <p>
  119. 商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介品介绍商品介绍
  120. </p>
  121. <div class="price">
  122. <div class="iconfont icon-rmb">203</div>
  123. <div>看相似</div>
  124. </div>
  125. </li>
  126. <li class="item">
  127. <a href=""><img src="images/sp/sp-3.webp" alt="" /></a>
  128. <p>
  129. 商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介品介绍商品介绍
  130. </p>
  131. <div class="price">
  132. <div class="iconfont icon-rmb">203</div>
  133. <div>看相似</div>
  134. </div>
  135. </li>
  136. <li class="item">
  137. <a href=""><img src="images/sp/sp-4.webp" alt="" /></a>
  138. <p>
  139. 商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介品介绍商品介绍
  140. </p>
  141. <div class="price">
  142. <div class="iconfont icon-rmb">203</div>
  143. <div>看相似</div>
  144. </div>
  145. </li>
  146. <li class="item">
  147. <a href=""><img src="images/sp/sp-5.webp" alt="" /></a>
  148. <p>
  149. 商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介品介绍商品介绍
  150. </p>
  151. <div class="price">
  152. <div class="iconfont icon-rmb">203</div>
  153. <div>看相似</div>
  154. </div>
  155. </li>
  156. <li class="item">
  157. <a href=""><img src="images/sp/sp-6.webp" alt="" /></a>
  158. <p>
  159. 商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介品介绍商品介绍
  160. </p>
  161. <div class="price">
  162. <div class="iconfont icon-rmb">203</div>
  163. <div>看相似</div>
  164. </div>
  165. </li>
  166. </ul>
  167. </main>
  168. <footer>
  169. <div>
  170. <div class="iconfont icon-home"></div>
  171. <span>首页</span>
  172. </div>
  173. <div>
  174. <div class="iconfont icon-home"></div>
  175. <span>分类</span>
  176. </div>
  177. <div>
  178. <div class="iconfont icon-home"></div>
  179. <span>惊喜</span>
  180. </div>
  181. <div>
  182. <div class="iconfont icon-home"></div>
  183. <span>购物车</span>
  184. </div>
  185. <div>
  186. <div class="iconfont icon-home"></div>
  187. <span>未登入</span>
  188. </div>
  189. </footer>
  190. </body>
  191. </html>

CSS代码

初始化

  1. main > .nav {
  2. display: flex;
  3. flex-flow: row wrap;
  4. padding: 1rem;
  5. }
  6. main > .nav img {
  7. height: 4rem;
  8. width: 4rem;
  9. }
  10. main .nav li {
  11. flex-basis: 20%;
  12. display: flex;
  13. flex-flow: column wrap;
  14. align-items: center;
  15. }
  16. main .ms {
  17. background: white;
  18. padding: 1rem;
  19. margin: 1rem 0;
  20. }
  21. main > .ms > .ms-top {
  22. font-size: 1.3rem;
  23. height: 3rem;
  24. display: flex;
  25. justify-content: space-between;
  26. }
  27. main > .ms > .ms-top > .left {
  28. display: flex;
  29. }
  30. main > .ms > .ms-top > .left .notice {
  31. display: flex;
  32. height: 2rem;
  33. font-size: 1rem;
  34. border: 1px solid red;
  35. border-radius: 2rem;
  36. align-items: center;
  37. justify-content: center;
  38. }
  39. main > .ms > .ms-top > .left .tips {
  40. color: red;
  41. background: pink;
  42. border-radius: 2rem;
  43. padding: 0.3rem 0.5rem;
  44. }
  45. main > .ms > .ms-top > .right {
  46. color: red;
  47. font-size: 1.3rem;
  48. }
  49. main > .ms > .ms-body {
  50. display: flex;
  51. justify-content: space-around;
  52. }
  53. main > .ms > .ms-body > .item {
  54. text-align: center;
  55. }
  56. main > .ms > .ms-body > img {
  57. height: 12rem;
  58. width: 12rem;
  59. }
  60. main > .ms > .ms-body > .item > div:first-of-type {
  61. color: red;
  62. font-weight: border;
  63. }
  64. main > .ms > .ms-body > .item > div:last-of-type {
  65. text-decoration-line: line-through;
  66. }
  67. /* 推荐区 */
  68. main > .tj {
  69. font-size: 1.1rem;
  70. color: grey;
  71. display: flex;
  72. flex-flow: row wrap;
  73. justify-content: center;
  74. }
  75. main .tj .item {
  76. flex-basis: calc(50% - 3rem);
  77. padding: 1rem;
  78. background: white;
  79. display: flex;
  80. flex-flow: column nowrap;
  81. margin-left: 1rem;
  82. margin-bottom: 1rem;
  83. border-radius: 1rem;
  84. }
  85. main .tj .item:nth-of-type(even) {
  86. margin-right: 1rem;
  87. }
  88. main > .tj > .item img {
  89. width: 100%;
  90. height: 100%;
  91. }
  92. main .tj .item .price {
  93. display: flex;
  94. justify-content: space-between;
  95. }
  96. main .tj .item .price div:first-of-type {
  97. color: red;
  98. font-weight: bolder;
  99. }
  100. main .tj .item .price div:last-of-type {
  101. background-color: #f6f6f6;
  102. border-radius: 1rem;
  103. padding: 0.2rem 1rem;
  104. color: #666;
  105. }

头部

  1. header {
  2. display: flex;
  3. flex-flow: row nowrap;
  4. align-items: center;
  5. }
  6. .iconfont.icon-menu {
  7. flex: 1;
  8. text-align: center;
  9. font-size: 2.5rem;
  10. }
  11. header .search {
  12. background: white;
  13. flex: 6;
  14. border-style: inset;
  15. border-color: white;
  16. border-radius: 3rem;
  17. display: flex;
  18. padding: 0.5rem;
  19. }
  20. .search > .log {
  21. color: red;
  22. font-size: 2rm;
  23. flex: 0 1 4rem;
  24. text-align: center;
  25. line-height: 2rem;
  26. }
  27. .search > .iconfont.icon-search {
  28. color: black;
  29. flex: 0 1 4rem;
  30. text-align: center;
  31. line-height: 2rem;
  32. border-left: 1px solid grey;
  33. }
  34. .search > .words {
  35. flex: auto;
  36. border: none;
  37. outline: none;
  38. color: red;
  39. }
  40. header .login {
  41. flex: 1;
  42. color: white;
  43. text-align: center;
  44. }

主体

  1. main > .nav {
  2. display: flex;
  3. flex-flow: row wrap;
  4. padding: 1rem;
  5. }
  6. main > .nav img {
  7. height: 4rem;
  8. width: 4rem;
  9. }
  10. main .nav li {
  11. flex-basis: 20%;
  12. display: flex;
  13. flex-flow: column wrap;
  14. align-items: center;
  15. }
  16. main .ms {
  17. background: white;
  18. padding: 1rem;
  19. margin: 1rem 0;
  20. }
  21. main > .ms > .ms-top {
  22. font-size: 1.3rem;
  23. height: 3rem;
  24. display: flex;
  25. justify-content: space-between;
  26. }
  27. main > .ms > .ms-top > .left {
  28. display: flex;
  29. }
  30. main > .ms > .ms-top > .left .notice {
  31. display: flex;
  32. height: 2rem;
  33. font-size: 1rem;
  34. border: 1px solid red;
  35. border-radius: 2rem;
  36. align-items: center;
  37. justify-content: center;
  38. }
  39. main > .ms > .ms-top > .left .tips {
  40. color: red;
  41. background: pink;
  42. border-radius: 2rem;
  43. padding: 0.3rem 0.5rem;
  44. }
  45. main > .ms > .ms-top > .right {
  46. color: red;
  47. font-size: 1.3rem;
  48. }
  49. main > .ms > .ms-body {
  50. display: flex;
  51. justify-content: space-around;
  52. }
  53. main > .ms > .ms-body > .item {
  54. text-align: center;
  55. }
  56. main > .ms > .ms-body > img {
  57. height: 12rem;
  58. width: 12rem;
  59. }
  60. main > .ms > .ms-body > .item > div:first-of-type {
  61. color: red;
  62. font-weight: border;
  63. }
  64. main > .ms > .ms-body > .item > div:last-of-type {
  65. text-decoration-line: line-through;
  66. }
  67. /* 推荐区 */
  68. main > .tj {
  69. font-size: 1.1rem;
  70. color: grey;
  71. display: flex;
  72. flex-flow: row wrap;
  73. justify-content: center;
  74. }
  75. main .tj .item {
  76. flex-basis: calc(50% - 3rem);
  77. padding: 1rem;
  78. background: white;
  79. display: flex;
  80. flex-flow: column nowrap;
  81. margin-left: 1rem;
  82. margin-bottom: 1rem;
  83. border-radius: 1rem;
  84. }
  85. main .tj .item:nth-of-type(even) {
  86. margin-right: 1rem;
  87. }
  88. main > .tj > .item img {
  89. width: 100%;
  90. height: 100%;
  91. }
  92. main .tj .item .price {
  93. display: flex;
  94. justify-content: space-between;
  95. }
  96. main .tj .item .price div:first-of-type {
  97. color: red;
  98. font-weight: bolder;
  99. }
  100. main .tj .item .price div:last-of-type {
  101. background-color: #f6f6f6;
  102. border-radius: 1rem;
  103. padding: 0.2rem 1rem;
  104. color: #666;
  105. }

页脚

  1. footer {
  2. display: flex;
  3. justify-content: space-around;
  4. align-items: center;
  5. }
  6. footer > div {
  7. display: flex;
  8. flex-flow: column nowrap;
  9. align-items: center;
  10. }
  11. footer > .iconfont {
  12. font-size: 2rem;
  13. }
  14. footer > div > span {
  15. font-size: 1rem;
  16. }
  17. footer > div:hover {
  18. cursor: pointer;
  19. }

总体定位

  1. @import url("reset.css");
  2. /* 头部 */
  3. header {
  4. background-color: red;
  5. color: white;
  6. height: 4.4rem;
  7. position: fixed;
  8. left: 0;
  9. right: 0;
  10. top: 0;
  11. z-index: 100;
  12. }
  13. /* 主题 */
  14. main {
  15. position: absolute;
  16. top: 4.4rem;
  17. right: 0;
  18. left: 0;
  19. bottom: 4.4rem;
  20. }
  21. /* 页脚 */
  22. footer {
  23. background-color: gray;
  24. color: white;
  25. height: 4.4rem;
  26. position: fixed;
  27. left: 0;
  28. right: 0;
  29. bottom: 0;
  30. }

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议