ASCII码 ASCII码

简单淘宝首页案例

发布于:2022-04-17 14:13:57  栏目:技术文档

页面效果

直接看图

看完上面图片的效果,我们再来看看代码部分" class="reference-link">看完上面图片的效果,我们再来看看代码部分

html代码

  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>Document</title>
  7. <link rel="stylesheet" href="css/reset.css">
  8. <link rel="stylesheet" href="css/header.css">
  9. <link rel="stylesheet" href="//at.alicdn.com/t/font_3332366_vouiuorsybs.css">
  10. <link rel="stylesheet" href="css/footer.css">
  11. <link rel="stylesheet" href="css/main.css">
  12. </head>
  13. <body>
  14. <!-- 首页头部 -->
  15. <header class="header">
  16. <!-- 搜索框 -->
  17. <div class="apptop">
  18. <img src="img/taobao.png" alt="">
  19. <div class="search">
  20. <span>寻找宝贝店铺</span>
  21. <div>
  22. <span> 搜索</span>
  23. </div>
  24. </div>
  25. <a href="">
  26. <img src="img/qiandao.png" alt="">
  27. </a>
  28. </div>
  29. <!-- 导航 -->
  30. <div class="nav">
  31. <div class="item">
  32. <img src="img/nav/nav1.png" alt="">
  33. <span>购物车</span>
  34. </div>
  35. <div class="item">
  36. <img src="img/nav/nav2.png" alt="">
  37. <span>手机类型</span>
  38. </div>
  39. <div class="item">
  40. <img src="img/nav/nav3.png" alt="">
  41. <span>今日爆款</span>
  42. </div>
  43. <div class="item">
  44. <img src="img/nav/nav4.png" alt="">
  45. <span>土鲜好货</span>
  46. </div>
  47. <div class="item">
  48. <img src="img/nav/nav5.png" alt="">
  49. <span>飞猪旅行</span>
  50. </div>
  51. <div class="item">
  52. <img src="img/nav/nav6.png" alt="">
  53. <span>天猫新品</span>
  54. </div>
  55. <div class="item">
  56. <img src="img/nav/nav7.png" alt="">
  57. <span>阿里拍卖</span>
  58. </div>
  59. <div class="item">
  60. <img src="img/nav/nav8.png" alt="">
  61. <span>领淘金币</span>
  62. </div>
  63. <div class="item">
  64. <img src="img/nav/nav9.png" alt="">
  65. <span>天猫国际</span>
  66. </div>
  67. <div class="item">
  68. <img src="img/nav/nav10png.png" alt="">
  69. <span>淘宝吃货</span>
  70. </div>
  71. </div>
  72. </header>
  73. <!-- 主体 -->
  74. <main>
  75. <!-- 优惠价格区 -->
  76. <div class="main-start">
  77. <div class="item">
  78. <div class="item-between">
  79. <div class="discount">
  80. <div>聚划算</div>
  81. <div>品牌折扣</div>
  82. </div>
  83. <a href=""><img src="img/youhuo/1.webp" alt=""></a>
  84. </div>
  85. <a href=""><img src="img/youhuo/2.webp" alt=""></a>
  86. </div>
  87. <div class="item">
  88. <div class="item-between">
  89. <div class="discount">
  90. <div>天天特卖</div>
  91. <div>1元秒杀</div>
  92. </div>
  93. <a href=""><img src="img/youhuo/3.webp" alt=""></a>
  94. </div>
  95. <a href=""><img src="img/youhuo/4.webp" alt=""></a>
  96. </div>
  97. <div class="item">
  98. <div class="item-between">
  99. <div class="discount">
  100. <div>有好货</div>
  101. <div>好口碑</div>
  102. </div>
  103. <a href=""><img src="img/youhuo/5.webp" alt=""></a>
  104. </div>
  105. <a href=""><img src="img/youhuo/6.webp" alt=""></a>
  106. </div>
  107. <div class="item">
  108. <div class="item-between">
  109. <div class="discount">
  110. <div>每日好店</div>
  111. <div>特色</div>
  112. </div>
  113. <a href=""><img src="img/youhuo/7.webp" alt=""></a>
  114. </div>
  115. <a href=""><img src="img/youhuo/8.webp" alt=""></a>
  116. </div>
  117. </div>
  118. <!-- 中心内容 -->
  119. <div class="main-center">
  120. <!-- 左边商品列表 -->
  121. <div>
  122. <!-- 每一个商品 -->
  123. <a href="" class="item">
  124. <img src="img/center/1.webp" alt="">
  125. <div class="item-title">
  126. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  127. </div>
  128. <div class="item-center">
  129. <span class="iconfont icon-jinqian"></span>
  130. <span class="item-price"> 245</span>
  131. <span class="item-pur">100+人已购买</span>
  132. </div>
  133. </a>
  134. <!-- 每一个商品 -->
  135. <a href="" class="item">
  136. <img src="img/center/3.webp" alt="">
  137. <div class="item-title">
  138. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  139. </div>
  140. <div class="item-center">
  141. <span class="iconfont icon-jinqian"></span>
  142. <span class="item-price"> 245</span>
  143. <span class="item-pur">100+人已购买</span>
  144. </div>
  145. </a>
  146. <!-- 每一个商品 -->
  147. <a href="" class="item">
  148. <img src="img/center/5.webp" alt="">
  149. <div class="item-title">
  150. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  151. </div>
  152. <div class="item-center">
  153. <span class="iconfont icon-jinqian"></span>
  154. <span class="item-price"> 245</span>
  155. <span class="item-pur">100+人已购买</span>
  156. </div>
  157. </a>
  158. <!-- 每一个商品 -->
  159. <a href="" class="item">
  160. <img src="img/center/7.webp" alt="">
  161. <div class="item-title">
  162. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  163. </div>
  164. <div class="item-center">
  165. <span class="iconfont icon-jinqian"></span>
  166. <span class="item-price"> 245</span>
  167. <span class="item-pur">100+人已购买</span>
  168. </div>
  169. </a>
  170. <!-- 每一个商品 -->
  171. <a href="" class="item">
  172. <img src="img/center/9.webp" alt="">
  173. <div class="item-title">
  174. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  175. </div>
  176. <div class="item-center">
  177. <span class="iconfont icon-jinqian"></span>
  178. <span class="item-price"> 245</span>
  179. <span class="item-pur">100+人已购买</span>
  180. </div>
  181. </a>
  182. <!-- 每一个商品 -->
  183. <a href="" class="item">
  184. <img src="img/center/11.webp" alt="">
  185. <div class="item-title">
  186. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  187. </div>
  188. <div class="item-center">
  189. <span class="iconfont icon-jinqian"></span>
  190. <span class="item-price"> 245</span>
  191. <span class="item-pur">100+人已购买</span>
  192. </div>
  193. </a>
  194. <!-- 每一个商品 -->
  195. <a href="" class="item">
  196. <img src="img/center/13.webp" alt="">
  197. <div class="item-title">
  198. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  199. </div>
  200. <div class="item-center">
  201. <span class="iconfont icon-jinqian"></span>
  202. <span class="item-price"> 245</span>
  203. <span class="item-pur">100+人已购买</span>
  204. </div>
  205. </a>
  206. </div>
  207. <!-- 右边商品列表 -->
  208. <div>
  209. <!-- 每一个商品 -->
  210. <a href="" class="item">
  211. <img src="img/center/2.webp" alt="">
  212. <div class="item-title">
  213. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  214. </div>
  215. <div class="item-center">
  216. <span class="iconfont icon-jinqian"></span>
  217. <span class="item-price"> 245</span>
  218. <span class="item-pur">100+人已购买</span>
  219. </div>
  220. </a>
  221. <!-- 每一个商品 -->
  222. <a href="" class="item">
  223. <img src="img/center/4.webp" alt="">
  224. <div class="item-title">
  225. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  226. </div>
  227. <div class="item-center">
  228. <span class="iconfont icon-jinqian"></span>
  229. <span class="item-price"> 245</span>
  230. <span class="item-pur">100+人已购买</span>
  231. </div>
  232. </a>
  233. <!-- 每一个商品 -->
  234. <a href="" class="item">
  235. <img src="img/center/6.webp" alt="">
  236. <div class="item-title">
  237. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  238. </div>
  239. <div class="item-center">
  240. <span class="iconfont icon-jinqian"></span>
  241. <span class="item-price"> 245</span>
  242. <span class="item-pur">100+人已购买</span>
  243. </div>
  244. </a>
  245. <!-- 每一个商品 -->
  246. <a href="" class="item">
  247. <img src="img/center/8.webp" alt="">
  248. <div class="item-title">
  249. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  250. </div>
  251. <div class="item-center">
  252. <span class="iconfont icon-jinqian"></span>
  253. <span class="item-price"> 245</span>
  254. <span class="item-pur">100+人已购买</span>
  255. </div>
  256. </a>
  257. <!-- 每一个商品 -->
  258. <a href="" class="item">
  259. <img src="img/center/10.webp" alt="">
  260. <div class="item-title">
  261. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  262. </div>
  263. <div class="item-center">
  264. <span class="iconfont icon-jinqian"></span>
  265. <span class="item-price"> 245</span>
  266. <span class="item-pur">100+人已购买</span>
  267. </div>
  268. </a>
  269. <!-- 每一个商品 -->
  270. <a href="" class="item">
  271. <img src="img/center/12.webp" alt="">
  272. <div class="item-title">
  273. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  274. </div>
  275. <div class="item-center">
  276. <span class="iconfont icon-jinqian"></span>
  277. <span class="item-price"> 245</span>
  278. <span class="item-pur">100+人已购买</span>
  279. </div>
  280. </a>
  281. <!-- 每一个商品 -->
  282. <a href="" class="item">
  283. <img src="img/center/14.webp" alt="">
  284. <div class="item-title">
  285. <span>高级感全棉纯棉60支贡缎棉南通床上四件套可定制床笠款柔软北欧风</span>
  286. </div>
  287. <div class="item-center">
  288. <span class="iconfont icon-jinqian"></span>
  289. <span class="item-price"> 245</span>
  290. <span class="item-pur">100+人已购买</span>
  291. </div>
  292. </a>
  293. </div>
  294. </div>
  295. </main>
  296. <!-- 底部 -->
  297. <footer class="footer">
  298. <div >
  299. <span class="iconfont icon-taobao"></span>
  300. </div>
  301. <div>
  302. <span class="iconfont icon-gouwuche "></span>
  303. <span>购物车</span>
  304. </div>
  305. <div>
  306. <span class="iconfont icon-wode "></span>
  307. <span>我的淘宝</span>
  308. </div>
  309. </footer>
  310. </body>
  311. </html>

CSS代码部分

偷个懒,就不写注释" class="reference-link">偷个懒,就不写注释

初始化部分

  1. *{
  2. margin: 0;
  3. padding: 0;
  4. box-sizing: border-box;
  5. }
  6. /* 首先确认1vw? */
  7. html{
  8. font-size: calc(100vw/3.75);
  9. }
  10. li{
  11. list-style: none;
  12. }
  13. a{
  14. text-decoration: none;
  15. }
  16. @media (max-width:350px){
  17. :root{
  18. font-size: .85rem;
  19. }
  20. }
  21. @media(min-width:780px){
  22. :root{
  23. font-size: 1.5rem;
  24. }
  25. }
  26. body{
  27. font-size: .16rem;
  28. background-color:#f4f4f4 ;
  29. }

heade部分

  1. .header{
  2. width: 100vw;
  3. /* 设置为相对定位 */
  4. position: relative;
  5. }
  6. .header .apptop{
  7. position: fixed;
  8. top: 0;
  9. left: 0;
  10. right: 0;
  11. z-index: 99;
  12. display: grid;
  13. grid-template-columns: .6rem 1fr .40rem;
  14. place-items: center;
  15. background-color: white;
  16. }
  17. .header .apptop>img{
  18. padding-left: .1rem;
  19. width: 100%;
  20. }
  21. .header .apptop .search{
  22. width: 2.5rem;
  23. background-color: white;
  24. border: .01rem solid coral;
  25. display: grid;
  26. grid-template-columns: 1fr .6rem;
  27. border-radius: .4rem;
  28. }
  29. .header .apptop .search>span{
  30. place-self: start;
  31. padding: .1rem ;
  32. color:#666666;
  33. }
  34. .header .apptop .search>div{
  35. margin: .05rem 0;
  36. justify-self: end;
  37. background-color: coral;
  38. border-radius: 1rem;
  39. width: .6rem;
  40. display: grid;
  41. place-items: center;
  42. }
  43. .header .apptop .search>div>span{
  44. color: aliceblue;
  45. }
  46. .header .apptop>a>img{
  47. width: 100%;
  48. padding-right: .1rem;
  49. place-self: center;
  50. }
  51. /* 导航 */
  52. .header .nav{
  53. position: absolute;
  54. top: .55rem;
  55. left: 0;
  56. right: 0;
  57. background-color: white;
  58. border-radius: .1rem;
  59. display: grid;
  60. grid-template-columns: repeat(5,1fr);
  61. }
  62. .header .nav .item{
  63. padding: .02rem;
  64. display: grid;
  65. place-items: center;
  66. }
  67. .header .nav .item>img{
  68. width: 100%;
  69. }

main

  1. main{
  2. position: absolute;
  3. top:2.3rem;
  4. left: 0;
  5. right: 0;
  6. }
  7. main .main-start{
  8. background-color: white;
  9. display: grid;
  10. gap: .05rem;
  11. grid-template-columns: repeat(2,1fr);
  12. border-radius: .1rem;
  13. padding: .01rem .05rem;
  14. }
  15. main .main-start .item{
  16. display: grid;
  17. grid-template-columns: repeat(2,1fr);
  18. place-items: center;
  19. }
  20. main .main-start .item .item-between .discount{
  21. display: grid;
  22. grid-template-columns: repeat(2,1fr);
  23. place-items: center;
  24. font-size: .1rem;
  25. /* 文本不会换 */
  26. white-space: nowrap;
  27. }
  28. main .main-start .item .item-between .discount>div:first-of-type{
  29. font-size: .15rem;
  30. margin-right: .05rem;
  31. }
  32. main .main-start .item .item-between .discount>div:last-of-type{
  33. background-color: rgb(255, 66, 0);
  34. color: white;
  35. }
  36. main .main-start .item a img{
  37. width: 100%;
  38. }
  39. /* 中心商品 */
  40. main .main-center{
  41. height: 19.2rem;
  42. display: grid;
  43. gap: .05rem;
  44. grid-template-columns: repeat(2,1fr);
  45. border-radius: .1rem;
  46. margin-top: .15rem;
  47. }
  48. main .main-center .item{
  49. background-color: white;
  50. border-radius: .1rem;
  51. padding: .04rem;
  52. margin-bottom: .05rem;
  53. display: grid;
  54. }
  55. main .main-center .item img{
  56. width: 100%;
  57. }
  58. main .main-center .item .item-title{
  59. color: black;
  60. padding-left: .02rem;
  61. font-size: .13rem;
  62. }
  63. main .main-center .item .item-center{
  64. margin-top: .05rem;
  65. }
  66. main .main-center .item .icon-jinqian{
  67. color: #999999;
  68. }
  69. main .main-center .item .item-price{
  70. color: #ff5500;
  71. font-size: .14rem;
  72. }
  73. main .main-center .item .item-pur{
  74. font-size: .11rem;
  75. color: #999999;
  76. }
  1. .footer{
  2. position:fixed;
  3. left: 0;
  4. right: 0;
  5. bottom: 0;
  6. display: grid;
  7. grid-template-columns: repeat(3,1fr);
  8. place-items: center;
  9. background-color: white;
  10. border-radius: .1rem;
  11. }
  12. .footer>div{
  13. display: grid;
  14. place-items: center;
  15. }
  16. .footer>div .icon-taobao{
  17. color: coral;
  18. }
  19. .footer>div .icon-wode{
  20. color: skyblue;
  21. }
  22. .footer>div>span:first-of-type{
  23. font-size: .3rem;
  24. }
  25. .footer>div>span:nth-of-type(2){
  26. font-size: .13rem;
  27. }

还有用到的图片以及图标就不一一说了,都是千篇一律" class="reference-link">还有用到的图片以及图标就不一一说了,都是千篇一律

相关推荐
阅读 +