博客列表 >淘宝移动端布局实践

淘宝移动端布局实践

P粉317509817
P粉317509817原创
2022年03月30日 16:19:09748浏览

淘宝移动端布局实践

页面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. <title>仿淘宝移动端首页-2</title>
  8. <link rel="stylesheet" href="font_icon/iconfont.css" />
  9. <link rel="stylesheet" href="css/reset.css" />
  10. <link rel="stylesheet" href="css/header.css" />
  11. <link rel="stylesheet" href="css/footer.css" />
  12. <link rel="stylesheet" href="css/main.css" />
  13. </head>
  14. <body>
  15. <!-- 头部 -->
  16. <header>
  17. <!-- 顶部 -->
  18. <div class="top">
  19. <!-- logo -->
  20. <div class="logo iconfont icon-shejiaotubiao-08"></div>
  21. <!-- 搜索框 -->
  22. <div class="search">
  23. <div class="keys">
  24. <span class="iconfont icon-fangdajing"></span>
  25. <span>寻找宝贝店铺</span>
  26. </div>
  27. </div>
  28. </div>
  29. <!-- 轮播图 -->
  30. <div class="slider">
  31. <a href=""><img src="images/banner/banner1.jpg" alt="" /></a>
  32. </div>
  33. <!-- 导航组 -->
  34. <ul class="nav">
  35. <li class="item">
  36. <a href=""><img src="images/nav/nav6.png" alt="" /></a>
  37. <a href="">天猫新品</a>
  38. </li>
  39. <li class="item">
  40. <a href=""><img src="images/nav/nav3.png" alt="" /></a>
  41. <a href="">今日爆款</a>
  42. </li>
  43. <li class="item">
  44. <a href=""><img src="images/nav/nav1.png" alt="" /></a>
  45. <a href="">天猫超市</a>
  46. </li>
  47. <li class="item">
  48. <a href=""><img src="images/nav/nav2.png" alt="" /></a>
  49. <a href="">充值中心</a>
  50. </li>
  51. <li class="item">
  52. <a href=""><img src="images/nav/nav5.png" alt="" /></a>
  53. <a href="">机票酒店</a>
  54. </li>
  55. <li class="item">
  56. <a href=""><img src="images/nav/nav8.png" alt="" /></a>
  57. <a href="">金币庄园</a>
  58. </li>
  59. <li class="item">
  60. <a href=""><img src="images/nav/nav7.png" alt="" /></a>
  61. <a href="">阿里拍卖</a>
  62. </li>
  63. <li class="item">
  64. <a href=""><img src="images/nav/nav4.png" alt="" /></a>
  65. <a href="">分类</a>
  66. </li>
  67. <li class="item">
  68. <a href=""><img src="images/nav/nav7.png" alt="" /></a>
  69. <a href="">阿里拍卖</a>
  70. </li>
  71. <li class="item">
  72. <a href=""><img src="images/nav/nav4.png" alt="" /></a>
  73. <a href="">分类</a>
  74. </li>
  75. </ul>
  76. </header>
  77. <!-- 主体 -->
  78. <main style="height: 1600px">
  79. <!-- 1. 聚划算 -->
  80. <div class="top">
  81. <div class="item jhs">
  82. <div class="box">
  83. <h3 class="title">聚划算</h3>
  84. <div class="desc">
  85. <h4>品牌折扣</h4>
  86. <img src="images/items/item1.png" alt="" />
  87. </div>
  88. </div>
  89. <div class="box">
  90. <!-- 用实体空格表示占位符 -->
  91. <h3 class="title">&nbsp;</h3>
  92. <div class="desc">
  93. <h4>划算好货</h4>
  94. <img src="images/items/item2.png" alt="" />
  95. </div>
  96. </div>
  97. <div class="box">
  98. <h3 class="title">淘抢购</h3>
  99. <div class="desc">
  100. <h4>限时半价</h4>
  101. <img src="images/items/item3.png" alt="" />
  102. </div>
  103. </div>
  104. <div class="box">
  105. <h3 class="title">天天特价</h3>
  106. <div class="desc">
  107. <h4>9.9包邮</h4>
  108. <img src="images/items/item4.png" alt="" />
  109. </div>
  110. </div>
  111. </div>
  112. <div class="item right">
  113. <div class="box">
  114. <h3 class="title">淘宝直播 <span class="tag" style="background-color: red">LIVE</span></h3>
  115. <div class="detail">
  116. <div class="left">
  117. <span class="title">好物传送门</span>
  118. <img src="images/items/item5.png" alt="" />
  119. </div>
  120. <div class="right">
  121. <img src="images/items/item6.png" alt="" />
  122. </div>
  123. </div>
  124. </div>
  125. <div class="box">
  126. <h3 class="title">有好货&nbsp;<span class="tag" style="background-color: skyblue">品质好物</span></h3>
  127. <div class="detail">
  128. <div class="left">
  129. <span class="title" style="color: skyblue">全民口碑推荐</span>
  130. <img src="images/items/item7.png" alt="" />
  131. </div>
  132. <div class="right">
  133. <img src="images/items/item21.png" alt="" />
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. <div class="item right">
  139. <div class="box">
  140. <h3 class="title">每日好店 <span class="tag" style="background-color: orange">精选</span></h3>
  141. <div class="detail">
  142. <div class="left">
  143. <span class="title">深挖藏的店</span>
  144. <img src="images/items/item9.png" alt="" />
  145. </div>
  146. <div class="right">
  147. <img src="images/items/item10.png" alt="" />
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. <div class="item right">
  153. <div class="box">
  154. <h3 class="title">哇哦视频<span class="tag" style="background-color: orange">亲测</span></h3>
  155. <div class="detail">
  156. <div class="left">
  157. <span class="title">粉丝都爱看</span>
  158. <img src="images/items/item11.png" alt="" />
  159. </div>
  160. <div class="right">
  161. <img src="images/items/item12.png" alt="" />
  162. </div>
  163. </div>
  164. </div>
  165. </div>
  166. <!-- 底部滚动显示文本 -->
  167. <div class="item footer">
  168. <div class="title">淘宝头条</div>
  169. <div class="content">
  170. <span class="type">评测</span>
  171. <span style="font-size: larger">五款最强的防******</span>
  172. </div>
  173. </div>
  174. </div>
  175. <!-- 2. 商品列表 -->
  176. <!-- 商品列表 -->
  177. <div class="list">
  178. <div class="title">----- 你可能还喜欢 -----</div>
  179. <div class="block">
  180. <div class="unit">
  181. <div class="img">
  182. <img src="images/items/item8.webp" alt="" />
  183. </div>
  184. <div class="detail">
  185. <div class="desc">商品描述商品描述,商品描述商品描述,商品描述商品描述,</div>
  186. <div class="price"><span class="iconfont icon-rmb">89</span><span class="num">45人已购买</span></div>
  187. </div>
  188. </div>
  189. <div class="unit">
  190. <div class="img">
  191. <img src="images/items/item20.webp" alt="" />
  192. </div>
  193. <div class="detail">
  194. <div class="desc">商品描述商品描述,商品描述商品描述,商品描述商品描述,</div>
  195. <div class="price"><span class="iconfont icon-rmb">89</span><span class="num">45人已购买</span></div>
  196. </div>
  197. </div>
  198. <div class="unit">
  199. <div class="img">
  200. <img src="images/items/item14.webp" alt="" />
  201. </div>
  202. <div class="detail">
  203. <div class="desc">商品描述商品描述,商品描述商品描述,商品描述商品描述,</div>
  204. <div class="price"><span class="iconfont icon-rmb">89</span><span class="num">45人已购买</span></div>
  205. </div>
  206. </div>
  207. <div class="unit">
  208. <div class="img">
  209. <img src="images/items/item15.webp" alt="" />
  210. </div>
  211. <div class="detail">
  212. <div class="desc">商品描述商品描述,商品描述商品描述,商品描述商品描述,</div>
  213. <div class="price"><span class="iconfont icon-rmb">89</span><span class="num">45人已购买</span></div>
  214. </div>
  215. </div>
  216. <div class="unit">
  217. <div class="img">
  218. <img src="images/items/item16.webp" alt="" />
  219. </div>
  220. <div class="detail">
  221. <div class="desc">商品描述商品描述,商品描述商品描述,商品描述商品描述,</div>
  222. <div class="price"><span class="iconfont icon-rmb">89</span><span class="num">45人已购买</span></div>
  223. </div>
  224. </div>
  225. <div class="unit">
  226. <div class="img">
  227. <img src="images/items/item17.webp" alt="" />
  228. </div>
  229. <div class="detail">
  230. <div class="desc">商品描述商品描述,商品描述商品描述,商品描述商品描述,</div>
  231. <div class="price"><span class="iconfont icon-rmb">89</span><span class="num">45人已购买</span></div>
  232. </div>
  233. </div>
  234. <div class="unit">
  235. <div class="img">
  236. <img src="images/items/item18.webp" alt="" />
  237. </div>
  238. <div class="detail">
  239. <div class="desc">商品描述商品描述,商品描述商品描述,商品描述商品描述,</div>
  240. <div class="price"><span class="iconfont icon-rmb">89</span><span class="num">45人已购买</span></div>
  241. </div>
  242. </div>
  243. <div class="unit">
  244. <div class="img">
  245. <img src="images/items/item19.webp" alt="" />
  246. </div>
  247. <div class="detail">
  248. <div class="desc">商品描述商品描述,商品描述商品描述,商品描述商品描述,</div>
  249. <div class="price"><span class="iconfont icon-rmb">89</span><span class="num">45人已购买</span></div>
  250. </div>
  251. </div>
  252. <div class="unit">
  253. <div class="img">
  254. <img src="images/items/item17.webp" alt="" />
  255. </div>
  256. <div class="detail">
  257. <div class="desc">商品描述商品描述,商品描述商品描述,商品描述商品描述,</div>
  258. <div class="price" style="margin-left: 0.1rem;"><span class="iconfont icon-rmb" style="font-size: large;margin-right: .1rem;">89</span><span class="num">45人已购买</span></div>
  259. </div>
  260. </div>
  261. <div class="unit">
  262. <div class="img">
  263. <img src="images/items/item18.webp" alt="" />
  264. </div>
  265. <div class="detail">
  266. <div class="desc">商品描述商品描述,商品描述商品描述,商品描述商品描述,</div>
  267. <div class="price"><span class="iconfont icon-rmb">89</span><span class="num">45人已购买</span></div>
  268. </div>
  269. </div>
  270. <div class="unit">
  271. <div class="img">
  272. <img src="images/items/item19.webp" alt="" />
  273. </div>
  274. <div class="detail">
  275. <div class="desc">商品描述商品描述,商品描述商品描述,商品描述商品描述,</div>
  276. <div class="price"><span class="iconfont icon-rmb">89</span><span class="num">45人已购买</span></div>
  277. </div>
  278. </div>
  279. <div class="unit">
  280. <div class="img">
  281. <img src="images/items/item20.webp" alt="" />
  282. </div>
  283. <div class="detail">
  284. <div class="desc">商品描述商品描述,商品描述商品描述,商品描述商品描述,</div>
  285. <div class="price"><span class="iconfont icon-rmb">89</span><span class="num">45人已购买</span></div>
  286. </div>
  287. </div>
  288. </div>
  289. </div>
  290. </main>
  291. <!-- 底部 -->
  292. <footer>
  293. <div class="item active">
  294. <a href="" class="iconfont icon-shejiaotubiao-44"></a>
  295. </div>
  296. <div class="item">
  297. <a href="" class="iconfont icon-gouwuche"></a>
  298. <a href="">购物车</a>
  299. </div>
  300. <div class="item">
  301. <a href="" class="iconfont icon-wodetaobao"></a>
  302. <a href="">我的淘宝</a>
  303. </div>
  304. </footer>
  305. </body>
  306. </html>

页面css文件

header.css

  1. header {
  2. position: relative;
  3. }
  4. header .top {
  5. width: 100vw;
  6. background-color: coral;
  7. position: fixed;
  8. top: 0;
  9. left: 0;
  10. right: 0;
  11. display: grid;
  12. grid-template-columns: 0.35rem 1fr;
  13. padding: 0.05rem;
  14. /* 调整显示层级 */
  15. z-index: 99;
  16. }
  17. header .top .logo {
  18. color: white;
  19. font-size: 0.25rem;
  20. }
  21. header .top .search {
  22. background-color: orangered;
  23. color: #eee;
  24. display: grid;
  25. place-content: center;
  26. border-radius: 0.05rem;
  27. font-size: small;
  28. }
  29. /* 轮播图,用图片代替 */
  30. header .slider {
  31. height: 1.25rem;
  32. position: absolute;
  33. top: 0.35rem;
  34. }
  35. header .slider img,
  36. header .nav img {
  37. width: 100%;
  38. height: 100%;
  39. }
  40. /* 导航组 */
  41. header .nav {
  42. background-color: #fff;
  43. position: absolute;
  44. top: calc(0.35rem + 1.25rem);
  45. display: grid;
  46. grid-template-columns: repeat(5, 1fr);
  47. font-size: 0.11rem;
  48. padding: 0.2rem 0.1rem;
  49. }
  50. header .nav .item {
  51. display: grid;
  52. place-items: center;
  53. padding: 0 0.05rem;
  54. }
  55. header .nav .item a {
  56. padding: 0 0.05rem;
  57. }

main.css

  1. main {
  2. position: relative;
  3. top: calc(0.37rem + 1.25rem + 1.5rem);
  4. padding: 0.1rem;
  5. }
  6. main img {
  7. width: 100%;
  8. height: 100%;
  9. }
  10. main .top {
  11. background-color: #fff;
  12. border-radius: 0.1rem;
  13. min-height: 3rem;
  14. /* 3行2列 */
  15. display: grid;
  16. grid-template-columns: repeat(2, 1fr);
  17. gap: 0.1rem;
  18. padding: 0.1rem;
  19. }
  20. /* 最后一行,跨2列 */
  21. main .top .item:last-of-type {
  22. grid-column: span 2;
  23. /* background-color: yellow; */
  24. }
  25. /* 左上角的聚划算 */
  26. main .top .item.jhs {
  27. display: grid;
  28. grid-template-columns: repeat(2, 1fr);
  29. gap: 0.1rem;
  30. }
  31. main .top .item.jhs .box {
  32. display: grid;
  33. gap: 0.1rem;
  34. }
  35. main .top .item.jhs .box .desc {
  36. display: grid;
  37. background-color: rgb(243, 235, 236);
  38. border-radius: 0.1rem;
  39. padding: 0.1rem;
  40. }
  41. /* 右侧, 上下二组 */
  42. main .top .item.right {
  43. display: grid;
  44. gap: 0.1rem;
  45. }
  46. main .top .item.right .box {
  47. display: grid;
  48. }
  49. main .top .item.right .box .title {
  50. grid-column: span 2;
  51. }
  52. main .top .item.right .box .title .tag {
  53. color: #fff;
  54. font-weight: normal;
  55. padding: 1px;
  56. border-radius: 0.05rem;
  57. font-size: smaller;
  58. }
  59. main .top .item.right .box .detail {
  60. display: grid;
  61. grid-template-columns: repeat(2, 1fr);
  62. }
  63. main .top .item.right .box .detail .left {
  64. display: grid;
  65. }
  66. /* 底部公告 */
  67. main .item.footer {
  68. display: grid;
  69. grid-template-columns: 0.6rem 1fr;
  70. padding: 0.1rem 0;
  71. }
  72. main .item.footer .type {
  73. background-color: rgb(238, 202, 206);
  74. color: darkorange;
  75. padding: 2px 5px;
  76. border-radius: 3px;
  77. }
  78. main .item.footer .title {
  79. font-size: larger;
  80. font-weight: bolder;
  81. }
  82. main .list .title{
  83. color: #ff865e;
  84. font-size: large;
  85. font-weight: 600;
  86. margin: 0.2rem 0 0.1rem 0.8rem;
  87. padding: auto;
  88. }
  89. main .list .block {
  90. display: grid;
  91. grid-template-columns: repeat(2,1fr);
  92. gap: .1rem;
  93. }
  94. main .list .unit img{
  95. width: 100%;
  96. height: 100%;
  97. border-radius: .1rem .1rem 0 0;
  98. }
  99. main .list .unit {
  100. display: grid;
  101. grid-template-rows: 0.7fr 0.3fr;
  102. background-color: #fff;
  103. border-radius: 0 0 .1rem .1rem;
  104. }
  105. main .list .unit .detail .desc{
  106. padding:0.1rem;
  107. }
  108. main .list .unit .detail .price {
  109. margin-left: .1rem;
  110. color: #ff865e;
  111. }
  112. main .list .unit .detail .num{
  113. color: #d0d0d0;
  114. font-size: smaller;
  115. margin-left: 0.05rem;
  116. }
  1. footer {
  2. width: 100vw;
  3. height: 0.46rem;
  4. background-color: #fff;
  5. position: fixed;
  6. bottom: 0;
  7. left: 0;
  8. right: 0;
  9. display: grid;
  10. grid-template-columns: repeat(3, 1fr);
  11. place-items: center;
  12. }
  13. footer .item {
  14. display: grid;
  15. place-items: center;
  16. }
  17. footer .item .iconfont {
  18. font-size: 0.2rem;
  19. }
  20. footer .item.active .iconfont {
  21. font-size: 0.36rem;
  22. color: coral;
  23. }

效果:

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