博客列表 >仿京东移动端首页

仿京东移动端首页

培(信仰)
培(信仰)原创
2020年12月29日 15:53:45780浏览

仿京东移动端首页

检验之前所学内容,查漏补缺

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>仿京东移动版</title>
  7. <!-- 字体图标 -->
  8. <link rel="stylesheet" href="./static/icon-font/iconfont.css">
  9. <!-- 首页样式 -->
  10. <link rel="stylesheet" href="./static/CSS/index.css">
  11. <!-- 页眉样式 -->
  12. <link rel="stylesheet" href="./static/CSS/header.css">
  13. <!-- 主体 -->
  14. <!-- 打开APP -->
  15. <link rel="stylesheet" href="./static/CSS/openApp.css">
  16. <!-- 导航菜单 -->
  17. <link rel="stylesheet" href="./static/CSS/nav.css">
  18. <!-- 秒杀 -->
  19. <link rel="stylesheet" href="./static/CSS/ms.css">
  20. <!-- 猜你喜欢 -->
  21. <link rel="stylesheet" href="./static/CSS/tj.css">
  22. <!-- 页脚 -->
  23. <link rel="stylesheet" href="./static/CSS/footer.css">
  24. </head>
  25. <body>
  26. <!-- 页眉 -->
  27. <header class="header">
  28. <!-- 字体图标 -->
  29. <div class="menu iconfont icon-menu"></div>
  30. <!-- 搜索框 -->
  31. <div class="search">
  32. <div class="logo">JD</div>
  33. <div class="zoom iconfont icon-search"></div>
  34. <input type="text" class="word" placeholder="电脑">
  35. </div>
  36. <!-- 登录按钮 -->
  37. <a href="" class="login">登录</a>
  38. </header>
  39. <!-- 主体 -->
  40. <div class="openApp">
  41. <a href="">
  42. <img src="./static/images/jddog.png" alt="">
  43. <span>打开APP</span>
  44. </a>
  45. </div>
  46. <main class="main">
  47. <!-- 轮播图 -->
  48. <div class="lbpic">
  49. <a href="">
  50. <img src="./static/images/bg/bg.jpg" alt="">
  51. </a>
  52. </div>
  53. <!-- 主导航菜单 -->
  54. <nav class="nav">
  55. <ul>
  56. <li>
  57. <a href=""><img src="static/images/dh/nav-1.png" alt=""></a>
  58. <a href="">京东超市</a>
  59. </li>
  60. <li>
  61. <a href=""><img src="static/images/dh/nav-2.png" alt=""></a>
  62. <a href="">数码电器</a>
  63. </li>
  64. <li>
  65. <a href=""><img src="static/images/dh/nav-3.png" alt=""></a>
  66. <a href="">京东服饰</a>
  67. </li>
  68. <li>
  69. <a href=""><img src="static/images/dh/nav-4.png" alt=""></a>
  70. <a href="">京东生鲜</a>
  71. </li>
  72. <li>
  73. <a href=""><img src="static/images/dh/nav-5.png" alt=""></a>
  74. <a href="">京东到家</a>
  75. </li>
  76. <li>
  77. <a href=""><img src="static/images/dh/nav-6.png" alt=""></a>
  78. <a href="">充值缴费</a>
  79. </li>
  80. <li>
  81. <a href=""><img src="static/images/dh/nav-7.png" alt=""></a>
  82. <a href="">9.9元拼</a>
  83. </li>
  84. <li>
  85. <a href=""><img src="static/images/dh/nav-8.png" alt=""></a>
  86. <a href="">领券</a>
  87. </li>
  88. <li>
  89. <a href=""><img src="static/images/dh/nav-9.png" alt=""></a>
  90. <a href="">领金贴</a>
  91. </li>
  92. <li>
  93. <a href=""><img src="static/images/dh/nav-10.png" alt=""></a>
  94. <a href="">PLUS会员</a>
  95. </li>
  96. </ul>
  97. </nav>
  98. <!-- 秒杀 -->
  99. <div class="ms">
  100. <div class="ms-top">
  101. <div class="left">
  102. <div class="title">京东秒杀</div>
  103. <div class="notice">
  104. <div class="tips">10点场</div>
  105. <div class="time">10:10:10</div>
  106. </div>
  107. </div>
  108. <div class="right"><a href="">更多秒杀</a></div>
  109. </div>
  110. <div class="ms-body">
  111. <li class="item">
  112. <a href=""><img src="static/images/ms/ms-1.jpg" alt=""></a>
  113. <div class="iconfont icon-rmb">3790</div>
  114. <div class="iconfont icon-rmb">4590</div>
  115. </li>
  116. <li class="item">
  117. <a href=""><img src="static/images/ms/ms-2.jpg" alt=""></a>
  118. <div class="iconfont icon-rmb">69</div>
  119. <div class="iconfont icon-rmb">139</div>
  120. </li>
  121. <li class="item">
  122. <a href=""><img src="static/images/ms/ms-3.jpg" alt=""></a>
  123. <div class="iconfont icon-rmb">159</div>
  124. <div class="iconfont icon-rmb">219</div>
  125. </li>
  126. <li class="item">
  127. <a href=""><img src="static/images/ms/ms-4.jpg" alt=""></a>
  128. <div class="iconfont icon-rmb">299</div>
  129. <div class="iconfont icon-rmb">850</div>
  130. </li>
  131. <li class="item">
  132. <a href=""><img src="static/images/ms/ms-5.jpg" alt=""></a>
  133. <div class="iconfont icon-rmb">7099</div>
  134. <div class="iconfont icon-rmb">7499</div>
  135. </li>
  136. <li class="item">
  137. <a href=""><img src="static/images/ms/ms-6.jpg" alt=""></a>
  138. <div class="iconfont icon-rmb">238</div>
  139. <div class="iconfont icon-rmb">329</div>
  140. </li>
  141. </div>
  142. </div>
  143. <!-- 猜你喜欢 -->
  144. <h2 class="tj-title">猜你喜欢</h2>
  145. <ul class="tj">
  146. <li class="item">
  147. <a href="">
  148. <div><img src="static/images/tj/tj-1.jpg" alt=""></div>
  149. <p>商品介绍 商品介绍 商品介绍 商品介绍</p>
  150. <span class="iconfont icon-rmb">138</span>
  151. <span>看相似</span>
  152. </a>
  153. </li>
  154. <li class="item">
  155. <a href="">
  156. <div><img src="static/images/tj/tj-2.jpg" alt=""></div>
  157. <p>商品介绍 商品介绍 商品介绍 商品介绍</p>
  158. <span class="iconfont icon-rmb">138</span>
  159. <span>看相似</span>
  160. </a>
  161. </li>
  162. <li class="item">
  163. <a href="">
  164. <div><img src="static/images/tj/tj-3.jpg" alt=""></div>
  165. <p>商品介绍 商品介绍 商品介绍 商品介绍</p>
  166. <span class="iconfont icon-rmb">138</span>
  167. <span>看相似</span>
  168. </a>
  169. </li>
  170. <li class="item">
  171. <a href="">
  172. <div><img src="static/images/tj/tj-4.jpg" alt=""></div>
  173. <p>商品介绍 商品介绍 商品介绍 商品介绍</p>
  174. <span class="iconfont icon-rmb">138</span>
  175. <span>看相似</span>
  176. </a>
  177. </li>
  178. <li class="item">
  179. <a href="">
  180. <div><img src="static/images/tj/tj-5.jpg" alt=""></div>
  181. <p>商品介绍 商品介绍 商品介绍 商品介绍</p>
  182. <span class="iconfont icon-rmb">138</span>
  183. <span>看相似</span>
  184. </a>
  185. </li>
  186. <li class="item">
  187. <a href="">
  188. <div><img src="static/images/tj/tj-6.jpg" alt=""></div>
  189. <p>商品介绍 商品介绍 商品介绍 商品介绍</p>
  190. <span class="iconfont icon-rmb">138</span>
  191. <span>看相似</span>
  192. </a>
  193. </li>
  194. </ul>
  195. </main>
  196. <!-- 页脚 -->
  197. <footer class="footer">
  198. <a href="">
  199. <div class="iconfont icon-home"></div>
  200. <span>主页</span>
  201. </a>
  202. <a href="">
  203. <div class="iconfont icon-layers"></div>
  204. <span>分类</span>
  205. </a>
  206. <a href="">
  207. <div class="iconfont icon-kehuguanli"></div>
  208. <span>京喜</span>
  209. </a>
  210. <a href="">
  211. <div class="iconfont icon-shopping-cart"></div>
  212. <span>购物车</span>
  213. </a>
  214. <a href="">
  215. <div class="iconfont icon-user"></div>
  216. <span>未登录</span>
  217. </a>
  218. </footer>
  219. </body>
  220. </html>

static/css/reset.css

  1. /* 初始化 */
  2. * {
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: border-box;
  6. }
  7. li {
  8. list-style: none;
  9. }
  10. a {
  11. color: #7b7b7b;
  12. text-decoration: none;
  13. }
  14. body {
  15. background-color: #F6F6F6;
  16. }
  17. html {
  18. font-size: 10px;
  19. }
  20. /* 媒体查询 */
  21. @media screen and (min-width: 480px) {
  22. html {
  23. font-size: 12px;
  24. }
  25. }
  26. @media screen and (min-width: 640px) {
  27. html {
  28. font-size: 14px;
  29. }
  30. }
  31. @media screen and (min-width: 720px) {
  32. html {
  33. font-size: 16px;
  34. }
  35. }

static/css/index.css

  1. /* 导入初始样式 */
  2. @import './reset.css';
  3. /* 页眉样式 */
  4. .header {
  5. background-color: #e43130;
  6. height: 4.4rem;
  7. color: white;
  8. position: fixed;
  9. top: 0;
  10. left: 0;
  11. right: 0;
  12. z-index: 100;
  13. }
  14. /* 主体 */
  15. .main {
  16. background-color: #f6f6f6;
  17. position: absolute;
  18. top: 4.4rem;
  19. left: 0;
  20. right: 0;
  21. bottom:5rem;
  22. }
  23. /* 页脚 */
  24. .footer {
  25. background-color: #fafafa;
  26. height: 5rem;
  27. color: #666;
  28. box-shadow: 0 0 3px #999;
  29. position: fixed;
  30. bottom: 0;
  31. left: 0;
  32. right: 0;
  33. z-index: 200;
  34. }

static/css/header.css

  1. /* 页眉 */
  2. .header {
  3. display: flex;
  4. align-items: center;
  5. }
  6. .header .menu{
  7. text-align: center;
  8. flex:1;
  9. font-size: 2.5rem;
  10. }
  11. .header .search {
  12. text-align: center;
  13. padding:0.5rem;
  14. flex:6;
  15. display: flex;
  16. align-items: center;
  17. background-color: #f6f6f6;
  18. border-radius: 3rem;
  19. height: 3rem;
  20. }
  21. .header .search .logo {
  22. align-self: center;
  23. color:#e43130;
  24. font-size: 2rem;
  25. margin: 1.5rem;
  26. line-height: 2rem;
  27. }
  28. .header .search .zoom {
  29. align-self: center;
  30. flex:0 1 4rem;
  31. color:#ccc;
  32. border-left: 1px solid;
  33. text-align: center;
  34. line-height: 2rem;
  35. }
  36. .header .search .word {
  37. flex:auto;
  38. border:none;
  39. outline: none;
  40. background-color: #f6f6f6;
  41. color:#aaa;
  42. }
  43. .header .login {
  44. flex:1;
  45. text-align: center;
  46. color:white;
  47. font-size: 1.5rem;
  48. }

static/css/nav.css

  1. /* 主导航 */
  2. .main .lbpic {
  3. height: 9.35rem;
  4. text-align: center;
  5. background-image: -webkit-gradient(linear, left bottom, left top, from(#f1503b), color-stop(50%, #c82519));
  6. }
  7. .main .lbpic > a, .main .lbpic img {
  8. overflow: hidden;
  9. }
  10. .main .lbpic > a {
  11. width: -webkit-calc(100% - 1.25rem);
  12. width: calc(100% - 1.25rem);
  13. height: 9.35rem;
  14. border-radius: .35rem;
  15. line-height: 9.35;
  16. }
  17. .main .lbpic img {
  18. height: 9.35rem;
  19. vertical-align: middle
  20. }
  21. .main .nav {
  22. top: 9.5rem;
  23. }
  24. .main .nav ul {
  25. padding: 1rem;
  26. display: flex;
  27. flex-flow: row wrap;
  28. justify-content: space-between;
  29. /* top:9.35rem; */
  30. }
  31. .main .nav img {
  32. height: 4rem;
  33. width: 4rem;
  34. }
  35. .main .nav li {
  36. flex: 1 1 20%;
  37. display: flex;
  38. flex-flow: column nowrap;
  39. align-items: center;
  40. }

static/css/ms.css

  1. /* 秒杀 */
  2. .main .ms {
  3. background-color: #fff;
  4. border-radius: 1rem;
  5. padding: 1rem;
  6. margin: 1rem 0;
  7. }
  8. .main .ms .ms-top {
  9. font-size: 1.3rem;
  10. height: 3rem;
  11. display: flex;
  12. justify-content: space-between;
  13. }
  14. .main .ms .ms-top .left {
  15. display: flex;
  16. }
  17. .main .ms .ms-top .notice {
  18. font-size: 1.1rem;
  19. height: 2rem;
  20. border: 1px solid #e43130;
  21. border-radius: 2rem;
  22. margin-left: 1rem;
  23. display: flex;
  24. justify-content: center;
  25. align-items: center;
  26. }
  27. .main .ms .ms-top .left .notice .tips {
  28. background-color: #e43130;
  29. color: white;
  30. border-radius: 2rem;
  31. padding: 0.3rem 0.5rem;
  32. }
  33. .main .ms .ms-top .notice .time {
  34. padding: 0.3rem 0.5rem;
  35. }
  36. .main .ms .ms-top .right a{
  37. color: #e43130;
  38. }
  39. /* 主题区 */
  40. .main .ms .ms-body {
  41. display: flex;
  42. flex-flow: row nowrap;
  43. justify-content: space-between;
  44. overflow: scroll;
  45. height: 10rem;
  46. }
  47. .main .ms .ms-body .item img {
  48. width: 6rem;
  49. height: 6rem;
  50. }
  51. .main .ms .ms-body .item div {
  52. font-size: 1.1rem;
  53. text-align: center;
  54. }
  55. .main .ms .ms-body .item .iconfont:first-of-type {
  56. color: #e43130;
  57. }
  58. .main .ms .ms-body .item .iconfont:last-of-type{
  59. color: #666666;
  60. text-decoration: line-through;
  61. text-decoration-color: #666666;
  62. }

static/css/openApp.css

  1. /* 打开app */
  2. .openApp {
  3. border: 1px solid #fff;
  4. background-color: rgba(255, 0, 0, 0.8);
  5. z-index: 100;
  6. /* 绝对定位 */
  7. position: absolute;
  8. /* 局顶部5.5rem */
  9. top:5.8rem;
  10. left:auto;
  11. /* 靠右 */
  12. right: 0;
  13. height: 3.2rem;
  14. width: 9rem;
  15. border-top-left-radius:30rem ;
  16. border-bottom-left-radius:30rem ;
  17. }
  18. .openApp img {
  19. width: 3rem;
  20. border:1px solid #fff;
  21. border-radius: 30rem;
  22. vertical-align: middle
  23. }
  24. .openApp a {
  25. color:white;
  26. font-size: 1.25rem;
  27. }

static/css/tj.css

  1. /* 猜你喜欢 */
  2. .main .tj-title {
  3. text-align: center;
  4. height: 4rem;
  5. line-height: 4rem;
  6. font-weight: 500;
  7. color:#555;
  8. }
  9. .main .tj {
  10. display: flex;
  11. flex-flow: wrap;
  12. }
  13. .main .tj .item {
  14. flex:1 1 calc(50%-2rem);
  15. overflow: hidden;
  16. display: flex;
  17. flex-flow: column nowrap;
  18. width: 50%;
  19. height: 50%;
  20. position: relative;
  21. }
  22. .main .tj .item:nth-of-type(odd){
  23. padding-right: 0.5rem;
  24. padding-left:1rem;
  25. padding-bottom: 1rem;
  26. }
  27. .main .tj .item:nth-of-type(even){
  28. padding-left: .5rem;
  29. padding-right: 1rem;
  30. padding-bottom: 1rem;
  31. }
  32. .main .tj .item img {
  33. width: 100%;
  34. height: 100%;
  35. border-top-left-radius: 1rem;
  36. border-top-right-radius: 1rem;
  37. }
  38. .main .tj .item span:first-of-type{
  39. color: red;
  40. font-size: 1rem;
  41. }
  42. .main .tj .item span:last-of-type{
  43. position:absolute;
  44. right: 0;
  45. background-color: #ccc;
  46. border-radius: 1rem;
  47. padding:.25rem;
  48. }

效果图

效果图

通过此次操作对css选择器有个更多的认识。对flex和position也有了更深的体会。

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