Blogger Information
Blog 13
fans 0
comment 0
visits 13150
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
flex弹性盒子学习三:仿站实战
小追
Original
849 people have browsed it

仿站实战,随意仿一个网站

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. <link href="font-icon.css" rel="stylesheet" />
  7. <link href="index.css" rel="stylesheet" />
  8. <title>仿站:每一件小事都值得庆祝!!!</title>
  9. </head>
  10. <body>
  11. <header>
  12. <!-- logo -->
  13. <div><img src="images/logo.png" alt="" /></div>
  14. <!-- 导航 -->
  15. <div>
  16. <a href=""><span class="iconfont"></span></a>
  17. <a href="">上海市</a>
  18. </div>
  19. <div>
  20. <a href=""><span class="iconfont"></span></a>
  21. <a href="">所有产品</a>
  22. </div>
  23. <div>
  24. <a href=""><span class="iconfont"></span></a>
  25. <a href="">首页</a>
  26. </div>
  27. <div>
  28. <a href=""><span class="iconfont"></span></a>
  29. <a href="">蛋糕</a>
  30. </div>
  31. <div>
  32. <a href=""><span class="iconfont"></span></a>
  33. <a href="">小食</a>
  34. </div>
  35. <div>
  36. <a href=""><span class="iconfont"></span></a>
  37. <a href="">最新活动</a>
  38. </div>
  39. <div>
  40. <a href=""><span class="iconfont"></span></a>
  41. <a href="">银行活动</a>
  42. </div>
  43. <div>
  44. <a href=""><span class="iconfont"></span></a>
  45. <a href="">会员中心</a>
  46. </div>
  47. <div>
  48. <a href=""><span class="iconfont"></span></a>
  49. <a href="">注册|登录</a>
  50. </div>
  51. <div>
  52. <a href=""><span class="iconfont"></span></a>
  53. <a href="">购物车</a>
  54. </div>
  55. <div>
  56. <a href=""><span class="iconfont"></span></a>
  57. <a href="">更多</a>
  58. </div>
  59. </header>
  60. <!--主内容1 轮播图 -->
  61. <div class="slider"><a href=""><img src="images/slider.png" alt="" /></a></div>
  62. <div class="container">
  63. <!-- 主内容2 标题 -->
  64. <div class="title">
  65. <img src="images/knifeFork.png" />
  66. <h3>新品推荐</h3>
  67. <p>New Recommend</p>
  68. <h4>New</h4>
  69. </div>
  70. <!-- 主内容3 广告商品组合 -->
  71. <div class="goods-hot">
  72. <a href=""><img src="images/1.jpg" alt="" /></a>
  73. <a href=""><img src="images/2.jpg" alt="" /></a>
  74. <a href=""><img src="images/3.jpg" alt="" /></a>
  75. </div>
  76. <!-- 主内容4 标题 -->
  77. <div class="title">
  78. <img src="images/knifeFork.png" alt="">
  79. <h3>本季推荐</h3>
  80. <p>Seasonal Recommend</p>
  81. <h4>Seasonal</h4>
  82. </div>
  83. <!--主内容5 广告商品大图 -->
  84. <div class="goods-hot"><img src="images/shangpin1.jpg" alt="" /></div>
  85. <!--主内容6 商品大区1 -->
  86. <!-- 商品区1 -->
  87. <div class="goods">
  88. <div class="goods-1">
  89. <div class="goods-title">
  90. <div class="goods-name">
  91. <p>海岸蓝调</p>
  92. <p>Côte d'Azur</p>
  93. </div>
  94. <div class="goods-go">
  95. <p>¥198</p>
  96. <span class="iconfont"></span>
  97. </div>
  98. </div>
  99. </div>
  100. <div class="goods-2">
  101. <div class="goods-title">
  102. <div class="goods-name">
  103. <p>海岸蓝调</p>
  104. <p>Côte d'Azur</p>
  105. </div>
  106. <div class="goods-go">
  107. <p>¥198</p>
  108. <span class="iconfont"></span>
  109. </div>
  110. </div>
  111. </div>
  112. <div class="goods-3">
  113. <div class="goods-title">
  114. <div class="goods-name">
  115. <p>海岸蓝调</p>
  116. <p>Côte d'Azur</p>
  117. </div>
  118. <div class="goods-go">
  119. <p>¥198</p>
  120. <span class="iconfont"></span>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. <!-- 商品区2 -->
  126. <div class="goods">
  127. <div class="goods-4">
  128. <div class="goods-title">
  129. <div class="goods-name">
  130. <p>海岸蓝调</p>
  131. <p>Côte d'Azur</p>
  132. </div>
  133. <div class="goods-go">
  134. <p>¥198</p>
  135. <span class="iconfont"></span>
  136. </div>
  137. </div>
  138. </div>
  139. <div class="goods-5">
  140. <div class="goods-title">
  141. <div class="goods-name">
  142. <p>海岸蓝调</p>
  143. <p>Côte d'Azur</p>
  144. </div>
  145. <div class="goods-go">
  146. <p>¥198</p>
  147. <span class="iconfont"></span>
  148. </div>
  149. </div>
  150. </div>
  151. <div class="goods-6">
  152. <div class="goods-title">
  153. <div class="goods-name">
  154. <p>海岸蓝调</p>
  155. <p>Côte d'Azur</p>
  156. </div>
  157. <div class="goods-go">
  158. <p>¥198</p>
  159. <span class="iconfont"></span>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. <!--主内容7 标题 -->
  165. <div class="title">
  166. <img src="images/knifeFork.png" alt="">
  167. <h3>萌系推荐</h3>
  168. <p>Seasonal Recommend</p>
  169. <h4>Seasonal</h4>
  170. </div>
  171. <!--主内容8 广告商品大图 -->
  172. <div class="goods-hot"><img src="images/shangpin2.jpg" alt="" /></div>
  173. <!--主内容9 商品大区2 -->
  174. <!-- 商品区3 -->
  175. <div class="goods">
  176. <div class="goods-7">
  177. <div class="goods-title">
  178. <div class="goods-name">
  179. <p>海岸蓝调</p>
  180. <p>Côte d'Azur</p>
  181. </div>
  182. <div class="goods-go">
  183. <p>¥198</p>
  184. <span class="iconfont"></span>
  185. </div>
  186. </div>
  187. </div>
  188. <div class="goods-8">
  189. <div class="goods-title">
  190. <div class="goods-name">
  191. <p>海岸蓝调</p>
  192. <p>Côte d'Azur</p>
  193. </div>
  194. <div class="goods-go">
  195. <p>¥198</p>
  196. <span class="iconfont"></span>
  197. </div>
  198. </div>
  199. </div>
  200. <div class="goods-9">
  201. <div class="goods-title">
  202. <div class="goods-name">
  203. <p>海岸蓝调</p>
  204. <p>Côte d'Azur</p>
  205. </div>
  206. <div class="goods-go">
  207. <p>¥198</p>
  208. <span class="iconfont"></span>
  209. </div>
  210. </div>
  211. </div>
  212. </div>
  213. <div class="goods">
  214. <div class="goods-10">
  215. <div class="goods-title">
  216. <div class="goods-name">
  217. <p>海岸蓝调</p>
  218. <p>Côte d'Azur</p>
  219. </div>
  220. <div class="goods-go">
  221. <p>¥198</p>
  222. <span class="iconfont"></span>
  223. </div>
  224. </div>
  225. </div>
  226. <div class="goods-11">
  227. <div class="goods-title">
  228. <div class="goods-name">
  229. <p>海岸蓝调</p>
  230. <p>Côte d'Azur</p>
  231. </div>
  232. <div class="goods-go">
  233. <p>¥198</p>
  234. <span class="iconfont"></span>
  235. </div>
  236. </div>
  237. </div>
  238. <div class="goods-12">
  239. <div class="goods-title">
  240. <div class="goods-name">
  241. <p>海岸蓝调</p>
  242. <p>Côte d'Azur</p>
  243. </div>
  244. <div class="goods-go">
  245. <span>¥198</span>
  246. <span class="iconfont"></span>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. </div>
  252. <!-- 页脚 -->
  253. <footer>
  254. <!-- 上 -->
  255. <div class="footer-up">
  256. <!-- 上左 -->
  257. <div class="up-left">
  258. <img src="images/logo2.png" alt="" />
  259. <a href="">订购热线:4006-678-678(8:00 - 20:00)</a>
  260. <a href="">客服邮箱:cs@mcake.com</a>
  261. <a href="">地址:上海市普陀区同普路1130弄3号楼</a>
  262. <a href="">食品生产许可证:SC12431010700121</a>
  263. </div>
  264. <!-- 上中 -->
  265. <div class="up-center">
  266. <div class="upcenter-left">
  267. <h4>关于我们</h4>
  268. <a href="">企业介绍</a>
  269. <a href="">媒体合作</a>
  270. <a href="">招贤纳士</a>
  271. <a href="">呼叫中心</a>
  272. </div>
  273. <div class="upcenter-center">
  274. <h4>帮助中心</h4>
  275. <a href="">投诉与建议</a>
  276. <a href="">会员权益</a>
  277. <a href="">购物指南</a>
  278. <a href="">支付类</a>
  279. <a href="">订单相关</a>
  280. <a href="">配送服务</a>
  281. </div>
  282. <div class="upcenter-right">
  283. <h4>发现</h4>
  284. <a href="">公告</a>
  285. </div>
  286. </div>
  287. <!-- 上右 -->
  288. <div class="up-right">
  289. <a href=""><img src="images/weibo.png" alt="" /></a>
  290. <a href=""><img src="images/weixin.png" alt="" /></a>
  291. </div>
  292. </div>
  293. <!-- 中间 -->
  294. <div class="footer-center">
  295. <!-- 中左 -->
  296. <div class="center-left">
  297. <a href="">上海卡法电子商务有限公司</a>
  298. <a href="">地址:上海市普陀区同普路1130弄3号楼</a>
  299. <a href="">洽谈电话:021-52691591</a>
  300. <a href="">社会信用代码:913101070678091460</a>
  301. <a href="">食品经营许可证:JY13101070034251</a>
  302. </div>
  303. <!-- 中中 -->
  304. <div class="center-center">
  305. <a href="">上海卡法电子商务有限公司北京分公司</a>
  306. <a href="">地址:北京市朝阳区东四环中路82号3座16层1908</a>
  307. <a href="">洽谈电话:010-52088262</a>
  308. <a href="">社会信用代码:911101053484280752</a>
  309. <a href="">食品经营许可证:JY11105212634724</a>
  310. </div>
  311. <!-- 中右 -->
  312. <div class="center-right">
  313. <a href="">上海卡法电子商务有限公司杭州分公司</a>
  314. <a href="">地址:杭州市拱墅区中环大厦607室</a>
  315. <a href="">洽谈电话:0571-28103688</a>
  316. <a href="">社会信用代码:913301060920344424</a>
  317. <a href="">食品经营许可证:JY13301050141226</a>
  318. </div>
  319. </div>
  320. <!-- 下 -->
  321. <div class="footer-down">
  322. <span>Copyright © 2012-2020 上海卡法电子商务有限公司 版权所有 沪ICP备12022075号</span>
  323. </div>
  324. </footer>
  325. </body>
  326. </html>

css代码:

  1. *{
  2. margin:0;
  3. padding:0;
  4. box-sizing:border-box;
  5. }
  6. a{
  7. text-decoration:none;
  8. color:#cccccc;
  9. }
  10. html{
  11. font-size:16px;
  12. }
  13. body{
  14. display:flex;
  15. flex-flow:column nowrap;
  16. }
  17. header{
  18. background-color:white;
  19. height:130px;
  20. display:flex;
  21. position:fixed;
  22. width:100vw;
  23. border:1px solid #cccccc;
  24. }
  25. header>div{
  26. display:flex;
  27. flex-flow:column nowrap;
  28. align-items:center;
  29. border-left:1px solid #cccccc;
  30. text-align:center;
  31. flex:0 0 90px;
  32. }
  33. header>div:first-of-type{
  34. margin-right:50px;
  35. padding-top:10px;
  36. width:180px;
  37. }
  38. header>div>a{
  39. flex-flow:column wrap;
  40. justify-content:center;
  41. position:relative;
  42. top:30%;
  43. font-size:0.8rem;
  44. }
  45. .iconfont{
  46. color:#cccccc;
  47. font-size:1.6rem;
  48. }
  49. header div:nth-last-of-type(-n + 3){
  50. position:relative;
  51. left:800px;
  52. }
  53. header div:nth-last-child(4){
  54. border-right:1px solid #cccccc;
  55. }
  56. header div:hover:not(:first-of-type){
  57. color:#000;
  58. border-top:3px solid #ffe32a;
  59. }
  60. header div a:hover{
  61. color:#000;
  62. }
  63. header div a span:hover{
  64. color:#000;
  65. }
  66. .container{
  67. width:1400px;
  68. margin:auto;
  69. }
  70. /* 轮播图 */
  71. .slider{
  72. margin:auto;
  73. }
  74. .title{
  75. width:1400px;
  76. margin:auto;
  77. height:380px;
  78. padding:120px 0;
  79. }
  80. .title>h3{
  81. font-size:2rem;
  82. margin-top:-15px;
  83. margin-left:80px;
  84. }
  85. .title>p{
  86. color:#cccccc;
  87. margin-left:80px;
  88. }
  89. .title>h4{
  90. font-size:1.8rem;
  91. margin-top:-50px;
  92. margin-left:700px;
  93. color:#cccccc;
  94. }
  95. /* 用商品做背景,可以做到文字在图片上显示 */
  96. .goods-1{
  97. background:url(images/dangao1.jpg);
  98. width:421px;
  99. height:421px;
  100. }
  101. .goods-2{
  102. background:url(images/dangao2.jpg);
  103. width:421px;
  104. height:421px;
  105. }
  106. .goods-3{
  107. background:url(images/dangao3.jpg);
  108. width:421px;
  109. height:421px;
  110. }
  111. .goods-4{
  112. background:url(images/dangao4.jpg);
  113. width:421px;
  114. height:421px;
  115. }
  116. .goods-5{
  117. background:url(images/dangao5.jpg);
  118. width:421px;
  119. height:421px;
  120. }
  121. .goods-6{
  122. background:url(images/dangao6.jpg);
  123. width:421px;
  124. height:421px;
  125. }
  126. .goods-7{
  127. background:url(images/dangao7.jpg);
  128. width:421px;
  129. height:421px;
  130. }
  131. .goods-8{
  132. background:url(images/dangao8.jpg);
  133. width:421px;
  134. height:421px;
  135. }
  136. .goods-9{
  137. background:url(images/dangao9.jpg);
  138. width:421px;
  139. height:421px;
  140. }
  141. .goods-10{
  142. background:url(images/dangao10.jpg);
  143. width:421px;
  144. height:421px;
  145. }
  146. .goods-11{
  147. background:url(images/dangao11.jpg);
  148. width:421px;
  149. height:421px;
  150. }
  151. .goods-12{
  152. background:url(images/dangao12.jpg);
  153. width:421px;
  154. height:421px;
  155. }
  156. .goods-hot{
  157. display:flex;
  158. justify-content:center;
  159. }
  160. .goods{
  161. height:968;
  162. margin:auto;
  163. display:flex;
  164. flex-flow:row nowrap;
  165. margin:30px 0;
  166. justify-content:space-evenly;
  167. }
  168. .goods>div{
  169. padding:10px;
  170. box-sizing:border-box;
  171. }
  172. .goods-name>p:last-of-type{
  173. color:#cccccc;
  174. font-size:0.8rem;
  175. }
  176. .goods-title{
  177. height:inherit;
  178. display:flex;
  179. flex-direction:column;
  180. justify-content:space-between;
  181. padding:20px;
  182. }
  183. .goods-name{
  184. width:80px;
  185. }
  186. .goods-go>.iconfont{
  187. width:30px;
  188. height:30px;
  189. background-color:#ffe32a;
  190. border-radius:50%;
  191. text-align:center;
  192. }
  193. .goods-go{
  194. width:100%;
  195. display:flex;
  196. flex-flow:row nowrap;
  197. justify-content:space-between;
  198. }
  199. /* 页脚 */
  200. footer{
  201. width:100vw;
  202. background-color:#000;
  203. color:white;
  204. display:flex;
  205. flex-flow:column nowrap;
  206. height:600px;
  207. padding-top:50px;
  208. font-size:0.8rem;
  209. }
  210. .footer-up{
  211. margin:auto;
  212. height:100px;
  213. width:1400px;
  214. display:flex;
  215. flex-flow:row nowrap;
  216. justify-content:center;
  217. }
  218. .up-left{
  219. width:400px;
  220. display:flex;
  221. flex-flow:column nowrap;
  222. }
  223. .up-center{
  224. width:400px;
  225. display:flex;
  226. flex-flow:row wrap;
  227. justify-content:center;
  228. }
  229. .up-right{
  230. width:400px;
  231. display:flex;
  232. justify-content:center;
  233. }
  234. .upcenter-left{
  235. width:120px;
  236. display:flex;
  237. flex-flow:column wrap;
  238. justify-content:flex-start;
  239. }
  240. .upcenter-center{
  241. width:120px;
  242. display:flex;
  243. flex-flow:column wrap;
  244. }
  245. .upcenter-right{
  246. width:120px;
  247. display:flex;
  248. flex-flow:column wrap;
  249. }
  250. .footer-center{
  251. width:1400px;
  252. height:100px;
  253. margin:auto;
  254. display:flex;
  255. flex-flow:row nowrap;
  256. justify-content:center;
  257. }
  258. .center-left{
  259. width:400px;
  260. display:flex;
  261. flex-flow:column nowrap;
  262. }
  263. .center-center{
  264. width:400px;
  265. display:flex;
  266. flex-flow:column nowrap;
  267. }
  268. .center-right{
  269. width:400px;
  270. display:flex;
  271. flex-flow:column nowrap;
  272. }
  273. .footer-down{
  274. width:1400px;
  275. margin:auto;
  276. display:flex;
  277. justify-content:center;
  278. }
  279. .up-left> img{
  280. width:143px;
  281. margin-bottom:10px;
  282. }

效果图:

  • 总结:仿站中发现很多对flex不熟练的地方,还需要多熟悉。仿站成果很多细节不到位,加油吧!
Correcting teacher:GuanhuiGuanhui

Correction status:qualified

Teacher's comments:goods中的宽高都是一样的,可以抽出来写成一个公共的class。
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