博客列表 >仿手机淘宝首页

仿手机淘宝首页

Jet的博客
Jet的博客原创
2023年02月13日 18:04:10304浏览

一、仿手机淘宝页面

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

  1. /* 初始化 */
  2. * {
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: border-box;
  6. }
  7. /* 链接 */
  8. a {
  9. text-decoration: none;
  10. color: #555;
  11. }
  12. li {
  13. list-style: none;
  14. }
  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. margin: auto;
  23. padding: 0 0.15rem;
  24. }
  25. body img {
  26. width: 100%;
  27. }
  28. @media (max-width: 320px) {
  29. html {
  30. font-size: 0.85px;
  31. }
  32. }
  33. @media (min-width: 640px) {
  34. html {
  35. font-size: 170px;
  36. }
  37. }
  38. header {
  39. top: 0;
  40. left: 0;
  41. right: 0;
  42. /* 调整显示层级,总在最前面 */
  43. z-index: 999;
  44. /* Grid 布局 */
  45. display: grid;
  46. /* 1行3列 */
  47. grid-template-columns: 0.58rem 1fr 0.43rem;
  48. grid-auto-rows: 0.5rem;
  49. place-items: center;
  50. gap: 0.1rem;
  51. background-color: rgb(244, 244, 244);
  52. }
  53. /* LOGO */
  54. header a.logo {
  55. padding-left: 0.1rem;
  56. }
  57. /* search */
  58. header > a.search {
  59. width: 100%;
  60. border: 1px solid #ff5000;
  61. height: 0.35rem;
  62. border-radius: 0.3rem;
  63. /* flex */
  64. display: flex;
  65. place-content: space-between;
  66. place-items: center;
  67. }
  68. /* 搜索框中的第一段文本 */
  69. header > a.search > span:first-child {
  70. padding-left: 0.1rem;
  71. }
  72. header > a.search > span:last-child {
  73. padding: 0.06rem 0.2rem;
  74. /* background-color: coral; */
  75. /* 渐变背景 */
  76. background: linear-gradient(to left, #ff5000, #ffc000);
  77. color: #fff;
  78. border-radius: 0.3rem;
  79. margin-right: 0.01rem;
  80. }
  81. /* 签到图标 */
  82. header > a.iconfont {
  83. color: #ff5000;
  84. font-size: 0.24rem;
  85. }
  86. header,
  87. footer {
  88. height: 50px;
  89. /* 页眉页脚:固定定位 */
  90. position: fixed;
  91. }
  92. /* main */
  93. main {
  94. background-color: rgb(244, 244, 244);
  95. min-height: 1800px;
  96. margin-bottom: 0.6rem;
  97. /* 相对定位,把整个主体向下偏移50px */
  98. position: relative;
  99. top: 0.5rem;
  100. display: grid;
  101. grid-template-rows: 1.75rem 2.3rem 1fr;
  102. }
  103. main > .navs {
  104. background-color: white;
  105. border-radius: 15px;
  106. display: grid;
  107. grid-template-columns: repeat(5,1fr);
  108. grid-template-rows: repeat(2,1fr);
  109. }
  110. main > .navs > .item {
  111. display: grid;
  112. place-items: center;
  113. }
  114. main > .entry {
  115. margin-top:10px;
  116. background-color: white;
  117. border-radius: 15px;
  118. display:grid;
  119. grid-template-columns: repeat(2,1fr);
  120. grid-template-rows: repeat(2,1fr);
  121. gap:5px 5px;
  122. }
  123. main > .entry > .item > .title{
  124. display: grid;
  125. grid-template-columns: repeat(2,0.65rem);
  126. }
  127. main > .entry > .item a img:nth-child(1){
  128. width: 0.7rem;
  129. background-color: yellow;
  130. }
  131. main > .entry > .item a img:nth-child(2){
  132. width: 2rem;
  133. }
  134. main > .list {
  135. margin-top:10px;
  136. margin-bottom: 0.6rem;
  137. border-radius: 15px;
  138. display:grid;
  139. grid-template-columns: repeat(2,1fr);
  140. grid-template-rows: repeat(7,1fr);
  141. gap:0 10px;
  142. }
  143. main > .list > .item {
  144. height:2.2rem;
  145. display: grid;
  146. grid-template-rows: 1.4rem 0.3rem;
  147. }
  148. main > .list > .item > .desc{
  149. background-color: white;
  150. height: 0.7rem;
  151. display: grid;
  152. grid-template-rows: 0.4rem 0.1rem;
  153. place-content: center;
  154. padding:0 10px;
  155. }
  156. main > .list > .item > .desc span:nth-child(1){
  157. color:red;
  158. }
  159. main > .list > .item > .desc span:nth-child(2){
  160. font-size: 0.10rem;
  161. color: gray;
  162. }
  163. main > .list > .item:nth-child(odd){
  164. place-content: start;
  165. }
  166. main > .list > .item:nth-child(even){
  167. place-content: center;
  168. }
  169. /* 底部 */
  170. footer {
  171. background-color: #ffffff;
  172. bottom: 0;
  173. left: 0;
  174. right: 0;
  175. z-index: 999;
  176. display: grid;
  177. grid-template-columns: repeat(3,1fr);
  178. place-items: center;
  179. }
  180. footer > a:nth-child(1) {
  181. color: #FF8002;
  182. }
  183. footer > a:nth-child(1) ~ *{
  184. display: grid;
  185. grid-template-rows: repeat(2,1fr);
  186. place-items: center;
  187. }
  188. footer > a {
  189. font-size: 10px;
  190. }



目前还存在2个问题,请教老师:

1、快速进入的布局还没研究好;

2、class引入的图标如何放大,就是底部淘宝那个图标;

先交下作业哈

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