Blogger Information
Blog 35
fans 0
comment 0
visits 17004
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
仿写淘宝移动端首页
三九三伏
Original
762 people have browsed it

一、成果展示

二、代码

为了代码展示方便,就不做工程化了,一个HTML文件和一个CSS方便直观查看。

HTML代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  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. <title></title>
  8. <link rel="stylesheet" href="test.css">
  9. <link rel="stylesheet" href="0718/font_icon/iconfont.css">
  10. </head>
  11. <body>
  12. <!-- 1. 页眉 -->
  13. <header>
  14. <!-- logo -->
  15. <a href="" class="logo"><img src="0718/images/taobao.png" alt="">
  16. </a>
  17. <!-- 搜索框 -->
  18. <a href="" class="search">
  19. <span>寻找宝贝店铺</span>
  20. <span>搜索</span>
  21. </a>
  22. <!-- 签到 -->
  23. <a href="" class="iconfont icon-qiandao-xuanzhong"></a>
  24. </header>
  25. <!-- 2. 主题 -->
  26. <main>
  27. <!-- 顶部导航 -->
  28. <ul class="navs">
  29. <li class="item">
  30. <a href=""><img src="0718/images/navs/tmxb.webp" alt=""></a>
  31. <a href="">天猫精品</a>
  32. </li>
  33. <li class="item">
  34. <a href=""><img src="0718/images/navs/jrbk.webp" alt="" /></a>
  35. <a href="">今日爆款</a>
  36. </li>
  37. <li class="item">
  38. <a href=""><img src="0718/images/navs/tmgj.webp" alt="" /></a>
  39. <a href="">天猫国际</a>
  40. </li>
  41. <li class="item">
  42. <a href=""><img src="0718/images/navs/fzlx.webp" alt="" /></a>
  43. <a href="">飞猪旅行</a>
  44. </li>
  45. <li class="item">
  46. <a href=""><img src="0718/images/navs/tmcx.webp" alt="" /></a>
  47. <a href="">天猫超市</a>
  48. </li>
  49. <li class="item">
  50. <a href=""><img src="0718/images/navs/tbch.webp" alt="" /></a>
  51. <a href="">淘宝吃货</a>
  52. </li>
  53. <li class="item">
  54. <a href=""><img src="0718/images/navs/sqk.webp" alt="" /></a>
  55. <a href="">省钱卡</a>
  56. </li>
  57. <li class="item">
  58. <a href=""><img src="0718/images/navs/ltjb.webp" alt="" /></a>
  59. <a href="">领淘金币</a>
  60. </li>
  61. <li class="item">
  62. <a href=""><img src="0718/images/navs/alpm.webp" alt="" /></a>
  63. <a href="">阿里拍卖</a>
  64. </li>
  65. <li class="item">
  66. <a href=""><img src="0718/images/navs/fl.webp" alt="" /></a>
  67. <a href="">分类</a>
  68. </li>
  69. </ul>
  70. <!-- 快速入口 -->
  71. <ul class="entry">
  72. <li class="item">
  73. <div class="title">
  74. <h3>聚划算</h3>
  75. <span>品牌折扣</span>
  76. </div>
  77. <a href=""><img src="0718/images/items/item-1.webp" alt=""></a>
  78. <a href=""><img src="0718/images/items/item-2.webp" alt=""></a>
  79. </li>
  80. <li class="item">
  81. <div class="title">
  82. <h3>天天特卖</h3>
  83. <span>1元秒杀</span>
  84. </div>
  85. <a href=""><img src="0718/images/items/item-3.webp" alt="" /></a>
  86. <a href=""><img src="0718/images/items/item-4.webp" alt="" /></a>
  87. </li>
  88. <li class="item">
  89. <div class="title">
  90. <h3>有好货</h3>
  91. <span style="background-color: deepskyblue">好口碑</span>
  92. </div>
  93. <a href=""><img src="0718/images/items/item-5.webp" alt="" /></a>
  94. <a href=""><img src="0718/images/items/item-6.webp" alt="" /></a>
  95. </li>
  96. <li class="item">
  97. <div class="title">
  98. <h3>每日好店</h3>
  99. <span style="background-color: orange">特色</span>
  100. </div>
  101. <a href=""><img src="0718/images/items/item-7.webp" alt="" /></a>
  102. <a href=""><img src="0718/images/items/item-8.webp" alt="" /></a>
  103. </li>
  104. </ul>
  105. <!-- 商品列表 -->
  106. <ul class="list">
  107. <li class="item">
  108. <a href=""><img src="0718/images/items/item-9.webp" alt="" /></a>
  109. <div class="desc">
  110. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  111. <div class="price">
  112. <span class="iconfont icon-renminbi_o">288</span>
  113. <span>123人已购买</span>
  114. </div>
  115. </div>
  116. </li>
  117. <li class="item">
  118. <a href=""><img src="0718/images/items/item-10.webp" alt="" /></a>
  119. <div class="desc">
  120. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  121. <div class="price">
  122. <span class="iconfont icon-renminbi_o">288</span>
  123. <span>123人已购买</span>
  124. </div>
  125. </div>
  126. </li>
  127. <li class="item">
  128. <a href=""><img src="0718/images/items/item-11.webp" alt="" /></a>
  129. <div class="desc">
  130. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  131. <div class="price">
  132. <span class="iconfont icon-renminbi_o">288</span>
  133. <span>123人已购买</span>
  134. </div>
  135. </div>
  136. </li>
  137. <li class="item">
  138. <a href=""><img src="0718/images/items/item-12.webp" alt="" /></a>
  139. <div class="desc">
  140. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  141. <div class="price">
  142. <span class="iconfont icon-renminbi_o">288</span>
  143. <span>123人已购买</span>
  144. </div>
  145. </div>
  146. </li>
  147. <li class="item">
  148. <a href=""><img src="0718/images/items/item-13.webp" alt="" /></a>
  149. <div class="desc">
  150. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  151. <div class="price">
  152. <span class="iconfont icon-renminbi_o">288</span>
  153. <span>123人已购买</span>
  154. </div>
  155. </div>
  156. </li>
  157. <li class="item">
  158. <a href=""><img src="0718/images/items/item-14.webp" alt="" /></a>
  159. <div class="desc">
  160. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  161. <div class="price">
  162. <span class="iconfont icon-renminbi_o">288</span>
  163. <span>123人已购买</span>
  164. </div>
  165. </div>
  166. </li>
  167. <li class="item">
  168. <a href=""><img src="0718/images/items/item-15.webp" alt="" /></a>
  169. <div class="desc">
  170. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  171. <div class="price">
  172. <span class="iconfont icon-renminbi_o">288</span>
  173. <span>123人已购买</span>
  174. </div>
  175. </div>
  176. </li>
  177. <li class="item">
  178. <a href=""><img src="0718/images/items/item-16.webp" alt="" /></a>
  179. <div class="desc">
  180. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  181. <div class="price">
  182. <span class="iconfont icon-renminbi_o">288</span>
  183. <span>123人已购买</span>
  184. </div>
  185. </div>
  186. </li>
  187. <li class="item">
  188. <a href=""><img src="0718/images/items/item-17.webp" alt="" /></a>
  189. <div class="desc">
  190. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  191. <div class="price">
  192. <span class="iconfont icon-renminbi_o">288</span>
  193. <span>123人已购买</span>
  194. </div>
  195. </div>
  196. </li>
  197. <li class="item">
  198. <a href=""><img src="0718/images/items/item-18.webp" alt="" /></a>
  199. <div class="desc">
  200. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  201. <div class="price">
  202. <span class="iconfont icon-renminbi_o">288</span>
  203. <span>123人已购买</span>
  204. </div>
  205. </div>
  206. </li>
  207. <li class="item">
  208. <a href=""><img src="0718/images/items/item-19.webp" alt="" /></a>
  209. <div class="desc">
  210. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  211. <div class="price">
  212. <span class="iconfont icon-renminbi_o">288</span>
  213. <span>123人已购买</span>
  214. </div>
  215. </div>
  216. </li>
  217. <li class="item">
  218. <a href=""><img src="0718/images/items/item-20.webp" alt="" /></a>
  219. <div class="desc">
  220. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  221. <div class="price">
  222. <span class="iconfont icon-renminbi_o">288</span>
  223. <span>123人已购买</span>
  224. </div>
  225. </div>
  226. </li>
  227. <li class="item">
  228. <a href=""><img src="0718/images/items/item-21.webp" alt="" /></a>
  229. <div class="desc">
  230. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  231. <div class="price">
  232. <span class="iconfont icon-renminbi_o">288</span>
  233. <span>123人已购买</span>
  234. </div>
  235. </div>
  236. </li>
  237. <li class="item">
  238. <a href=""><img src="0718/images/items/item-22.webp" alt="" /></a>
  239. <div class="desc">
  240. <a href="">商品描述商品描述商品描述商品描述商品描述</a>
  241. <div class="price">
  242. <span class="iconfont icon-renminbi_o">288</span>
  243. <span>123人已购买</span>
  244. </div>
  245. </div>
  246. </li>
  247. </ul>
  248. </main>
  249. <!-- 3. 页脚 -->
  250. <footer>
  251. <a href="" class="iconfont icon-taobao"></a>
  252. <a href="" class="iconfont icon-gouwuche">
  253. <span>购物车</span>
  254. </a>
  255. <a href="" class="iconfont icon-wode">
  256. <span>我的淘宝</span>
  257. </a>
  258. </footer>
  259. </body>
  260. </html>

CSS代码

附上test.css代码,字体图标css代码不展示,请自行到阿里图标了解。

  1. /* 重置效果 */
  2. body *{
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: border-box;
  6. }
  7. a{
  8. text-decoration: none;
  9. color: #999;
  10. }
  11. li{
  12. list-style: none;
  13. }
  14. /* 移动端布局方案 rem+vw */
  15. html{
  16. font-size: calc(100vw / 3.75);
  17. }
  18. body{
  19. font-size: 0.13rem;
  20. color: #333;
  21. background-color: #f4f4f4;
  22. /* 页面居中 */
  23. margin: aoto;
  24. /* 左右填充 */
  25. padding: 0 0.15rem;
  26. /* 滚动条自动隐藏 */
  27. overflow-y: auto;
  28. }
  29. body img{
  30. width:100%;
  31. }
  32. /* 媒体查询 */
  33. @media (max-width:320px) {
  34. html{
  35. font-size: 85px;
  36. }
  37. }
  38. @media (min-width:670px) {
  39. html{
  40. font-size: 170px;
  41. }
  42. }
  43. /* 页眉页脚定位 */
  44. header,footer{
  45. height: 50px;
  46. background-color: #f4f4f4;
  47. position:fixed;
  48. z-index: 100;
  49. }
  50. header{
  51. top: 0;
  52. left: 0;
  53. right: 0;
  54. }
  55. footer{
  56. bottom: 0;
  57. left: 0;
  58. right: 0;
  59. }
  60. /* 页眉布局 */
  61. header{
  62. display: grid;
  63. grid-template-columns: 0.58rem 1fr 0.33rem;
  64. place-items: center;
  65. gap: 0 0.1rem;
  66. grid-auto-rows: .5rem;
  67. }
  68. header a.logo{
  69. padding-left: .1rem;
  70. }
  71. header .search{
  72. width: 100%;
  73. border: 2px solid #ff0000;
  74. height: 0.3rem;
  75. border-radius: 0.3rem;
  76. display: flex;
  77. place-content: space-between;
  78. place-items: center;
  79. }
  80. header .search span:nth-of-type(1){
  81. padding-left: .1rem;
  82. color: #999;
  83. }
  84. header .search span:nth-of-type(2){
  85. /* background-color: #ff5000; */
  86. background: linear-gradient(to left, #ff5000, #ffa000);
  87. color: white;
  88. padding: 0.03rem 0.15rem;
  89. margin-right: 0.01rem;
  90. border-radius: 0.3rem;
  91. }
  92. header>a.iconfont{
  93. color: #ff5000;
  94. font-size: larger;
  95. }
  96. footer{
  97. border: 1px solid #ccc;
  98. display: grid;
  99. grid-template-columns: repeat(3,1fr);
  100. /* grid-auto-rows: .5rem; */
  101. place-content: space-around;
  102. place-items: center;
  103. font-size: smaller;
  104. }
  105. footer a{
  106. display: grid;
  107. place-items: center;
  108. }
  109. footer a:first-of-type{
  110. color: #ff5000;
  111. font-size: 0.35rem;
  112. }
  113. footer a span{
  114. font-size: 0.08rem;
  115. }
  116. main{
  117. min-height: 2000px;
  118. overflow: hidden;
  119. position: relative;
  120. top:50px;
  121. /* 让最后一行商品正常显示 */
  122. padding-bottom: 0.6rem;
  123. }
  124. /* 主体区公共样式 */
  125. main .navs, main .entry, main .list >.item{
  126. background-color: #fff;
  127. border-radius: 0.1rem;
  128. margin-top: 0.08rem;
  129. }
  130. /* 导航样式 */
  131. main .navs{
  132. display: grid;
  133. grid-template-columns: repeat(5,1fr);
  134. gap: 0 0.1rem;
  135. padding: 0.05rem;
  136. }
  137. main .navs .item{
  138. display: grid;
  139. place-items: center;
  140. }
  141. /* 快速入口样式 */
  142. main .entry{
  143. display: grid;
  144. grid-template-columns: repeat(2,1fr);
  145. padding: 0.05rem;
  146. }
  147. main .entry .item{
  148. display: grid;
  149. grid-template-columns: repeat(2,1fr);
  150. padding: 0.05rem;
  151. }
  152. main .entry .item .title{
  153. grid-column: span 2;
  154. display: flex;
  155. place-items: center;
  156. }
  157. main .entry .item:nth-of-type(-n+2){
  158. border-bottom: 1px solid #dedede;
  159. }
  160. main .entry .item .title span{
  161. background-color: #ff5000;
  162. color: #fff;
  163. border-radius: 0.05rem;
  164. font-size: smaller;
  165. padding: 0 0.03rem;
  166. margin-left: 0.05rem;
  167. }
  168. /* 商品列表样式 */
  169. main .list {
  170. display: grid;
  171. grid-template-columns: repeat(2,1fr);
  172. gap: 0 0.1rem;
  173. }
  174. main .list .item img{
  175. border-radius: 0.1rem 0.1rem 0 0;
  176. }
  177. main .list .item .desc{
  178. padding: 0.1rem;
  179. font-size: smaller;
  180. }
  181. main .list .item .price .iconfont{
  182. color: #ff5000;
  183. }
  184. main .list .item .desc .price span:first-of-type{
  185. }
  186. main .list .item .desc .price span:last-of-type{
  187. padding-left: 0.1rem;
  188. color: #bbb;
  189. }
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post