Blogger Information
Blog 20
fans 0
comment 1
visits 13235
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
仿smzdm移动端首页
zg的php学习
Original
492 people have browsed it

仿smzdm移动端首页

这个是个人练习flex与grid布局的习作。

HTML代码

  1. <body>
  2. <div class="home">
  3. <!-- 页面顶部 -->
  4. <div class="header">
  5. <div class="logo">
  6. <img src="img/header_logo.png" alt="" />
  7. </div>
  8. <div class="search">
  9. <form action="">
  10. <span class="iconfont icon-sousuo"></span>
  11. <input type="text" placeholder="搜索分类/品牌/商品" />
  12. </form>
  13. </div>
  14. <div class="login">
  15. <a href="">登录</a>
  16. </div>
  17. </div>
  18. <div class="main">
  19. <!-- 轮播图区 -->
  20. <div class="sub-banner">
  21. <div class="link-text">
  22. <h1>真实的消费内容社区</h1>
  23. <h2>用户好价爆料 专业达人评测 共建商品百科</h2>
  24. </div>
  25. <div class="info-banner-swiper">
  26. <img src="img/spbk.png" alt="" />
  27. </div>
  28. </div>
  29. <!-- 导航菜单 -->
  30. <div class="icon-list">
  31. <a href="" class="icon-box">
  32. <img src="img/hj.png" alt="" class="icon-desc" />
  33. <div class="txt">好价</div>
  34. </a>
  35. <a href="" class="icon-box">
  36. <img src="img/sq.png" alt="" class="icon-desc" />
  37. <div class="txt">社区</div>
  38. </a>
  39. <a href="" class="icon-box">
  40. <img src="img/ht.png" alt="" class="icon-desc" />
  41. <div class="txt">海淘</div>
  42. </a>
  43. <a href="" class="icon-box">
  44. <img src="img/lysy.png" alt="" class="icon-desc" />
  45. <div class="txt">0元试用</div>
  46. </a>
  47. <a href="" class="icon-box">
  48. <img src="img/yhj.png" alt="" class="icon-desc" />
  49. <div class="txt">优惠券</div>
  50. </a>
  51. <a href="" class="icon-box">
  52. <img src="img/ppdh.png" alt="" class="icon-desc" />
  53. <div class="txt">品牌导航</div>
  54. </a>
  55. </div>
  56. <!-- 商品列表 -->
  57. <div class="feed-content">
  58. <ul class="list">
  59. <li>
  60. <a href="" class="list-item">
  61. <div class="list-img">
  62. <img src="img/sp/sp1.png" alt="" />
  63. <div class="list-order">京东</div>
  64. </div>
  65. <div class="list-text">
  66. <span>10月1日 京东关注店铺领京豆</span>
  67. <span>好价排行Top1</span>
  68. <span>亲测领106京豆</span>
  69. </div>
  70. </a>
  71. <div class="list-link">
  72. <a href="">181</a>
  73. <a href="">72%</a>
  74. </div>
  75. </li>
  76. <li>
  77. <a href="" class="list-item">
  78. <div class="list-img">
  79. <img src="img/sp/sp2.jpg" alt="" />
  80. <div class="list-order">京东</div>
  81. </div>
  82. <div class="list-text">
  83. <span> COCONUT PLAM 椰树 椰子汁饮料 1000ml </span>
  84. <span>价格低于618</span>
  85. <span>7.9元 (需用券) </span>
  86. </div>
  87. </a>
  88. <div class="list-link">
  89. <a href="">181</a>
  90. <a href="">72%</a>
  91. </div>
  92. </li>
  93. <li>
  94. <a href="" class="list-item">
  95. <div class="list-img">
  96. <img src="img/sp/sp3.jpg" alt="" />
  97. <div class="list-order">天猫超市</div>
  98. </div>
  99. <div class="list-text">
  100. <span> 天地壹号 苹果醋饮料 330ml*15罐 </span>
  101. <span>好价排行Top4</span>
  102. <span>28.89 (需买... </span>
  103. </div>
  104. </a>
  105. <div class="list-link">
  106. <a href="">181</a>
  107. <a href="">72%</a>
  108. </div>
  109. </li>
  110. <li>
  111. <a href="" class="list-item">
  112. <div class="list-img">
  113. <img src="img/sp/sp3.jpg" alt="" />
  114. <div class="list-order">天猫超市</div>
  115. </div>
  116. <div class="list-text">
  117. <span> 天地壹号 苹果醋饮料 330ml*15罐 </span>
  118. <span>好价排行Top4</span>
  119. <span>28.89 (需买... </span>
  120. </div>
  121. </a>
  122. <div class="list-link">
  123. <a href="">181</a>
  124. <a href="">72%</a>
  125. </div>
  126. </li>
  127. </ul>
  128. </div>
  129. </div>
  130. <!-- 页面底部 -->
  131. <div class="footer-banner">
  132. <a href="">
  133. <div class="download-foot">
  134. <img src="img/download_logo.png" alt="" />
  135. <span class="download-info">
  136. <span>什么值得买</span>
  137. <br />
  138. <span>分享每一种值</span>
  139. </span>
  140. <span class="download-btn">下载APP</span>
  141. <span>x</span>
  142. </div>
  143. </a>
  144. </div>
  145. </div>
  146. </body>

CSS代码:

  1. /* 页面初始化 */
  2. * {
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: border-box;
  6. }
  7. :root {
  8. font-size: 10px;
  9. }
  10. body {
  11. font-size: 1.6rem;
  12. }
  13. a {
  14. text-decoration: none;
  15. }
  16. li {
  17. list-style: none;
  18. }
  19. @media (min-width: 480px) {
  20. html {
  21. font-size: 12px;
  22. }
  23. }
  24. @media (min-width: 640px) {
  25. html {
  26. font-size: 14px;
  27. }
  28. }
  29. @media (min-width: 720px) {
  30. html {
  31. font-size: 16px;
  32. }
  33. }
  34. /* 页面顶部 */
  35. .home {
  36. height: 100vh;
  37. display: grid;
  38. grid-template-rows: 4.4rem 1fr 6rem;
  39. background-color: #f6f6f6;
  40. }
  41. .home .main {
  42. height: calc(100vh - 4.4rem - 6rem);
  43. overflow-y: scroll;
  44. }
  45. .home .header {
  46. display: flex;
  47. place-items: center;
  48. background-color: white;
  49. }
  50. .home .header .logo {
  51. flex-basis: 11rem;
  52. }
  53. .home .header .logo img {
  54. width: 10rem;
  55. height: 1.9rem;
  56. padding-left: 0.5rem;
  57. }
  58. .home .header .search {
  59. flex-grow: 1;
  60. flex-basis: auto;
  61. background-color: #f6f6f6;
  62. border-radius: 1.5rem;
  63. padding: 0.2rem;
  64. }
  65. .home .header .search form {
  66. display: grid;
  67. grid-template-columns: auto 1fr;
  68. padding-left: 0.5rem;
  69. }
  70. .home .header .search input {
  71. border: none;
  72. outline: none;
  73. background-color: #f6f6f6;
  74. width: 100%;
  75. }
  76. .home .header .login {
  77. flex-basis: 5rem;
  78. padding-left: 1rem;
  79. font-size: 1.4rem;
  80. }
  81. /* 轮播图区 */
  82. .main .sub-banner {
  83. width: 100%;
  84. background: url("../img/banner_bg_10.png") no-repeat;
  85. background-size: cover;
  86. }
  87. .main .sub-banner .link-text {
  88. color: #fff;
  89. text-align: center;
  90. padding-top: 2.6rem;
  91. width: 100%;
  92. }
  93. .main .sub-banner .link-text h1 {
  94. font-size: 2rem;
  95. line-height: 2rem;
  96. font-weight: 700;
  97. margin-bottom: 1rem;
  98. }
  99. .main .sub-banner .link-text h2 {
  100. font-size: 1.2rem;
  101. line-height: 1.2rem;
  102. font-weight: 400;
  103. margin-bottom: 1rem;
  104. }
  105. .main .sub-banner .info-banner-swiper {
  106. width: 100%;
  107. padding: 1.2rem 2.4rem 0.8rem;
  108. }
  109. .main .sub-banner .info-banner-swiper img {
  110. width: calc(100vw - 4.8rem);
  111. border-radius: 6.6px;
  112. }
  113. /* 导航菜单 */
  114. .icon-list {
  115. display: flex;
  116. padding: 0.9rem 0.4rem;
  117. place-content: space-evenly;
  118. place-items: center;
  119. flex-direction: row;
  120. /* 子元素横向排列 */
  121. /* flex-direction: row; */
  122. /* 相对父元素水平居中 */
  123. /* justify-content: center; */
  124. /* 子元素相对父元素垂直居中 */
  125. align-items: center;
  126. }
  127. .icon-list .icon-box {
  128. display: flex;
  129. flex-direction: column;
  130. place-items: center;
  131. font-size: 12px;
  132. color: #888;
  133. }
  134. .icon-list .icon-box .icon-desc {
  135. width: 4rem;
  136. height: 4rem;
  137. }
  138. /* 商品列表 */
  139. .main .feed-content .list {
  140. display: grid;
  141. grid-template-columns: repeat(2, 1fr);
  142. gap: 1.5rem;
  143. padding: 1.5rem;
  144. }
  145. .main .feed-content .list-item .list-img > img {
  146. width: 100%;
  147. border-radius: 1rem 1rem 0 0;
  148. }
  149. .main .feed-content .list .list-item .list-text {
  150. display: flex;
  151. flex-direction: column;
  152. font-size: 1.2rem;
  153. }
  154. .list-img {
  155. position: relative;
  156. }
  157. .list-img .list-order {
  158. position: absolute;
  159. bottom: 1rem;
  160. left: 1rem;
  161. font-size: 0.6rem;
  162. color: #888;
  163. padding: 0 0.5rem;
  164. background-color: #f6f6f6;
  165. border-radius: 3px;
  166. }
  167. .main .feed-content .list > li span {
  168. padding: 0.3rem 0.5rem;
  169. }
  170. .list-text > span:first-of-type {
  171. color: black;
  172. font-size: 12px;
  173. }
  174. .list-text > span:first-of-type + span {
  175. color: #666;
  176. font-size: 10px;
  177. }
  178. .list-text > span:last-of-type {
  179. color: red;
  180. font-size: 12px;
  181. font-weight: bolder;
  182. }
  183. .list .list-link {
  184. color: #666;
  185. font-size: 12px;
  186. display: flex;
  187. width: 100%;
  188. place-items: center;
  189. place-content: space-evenly;
  190. }
  191. /* 页面底部 */
  192. .footer-banner {
  193. position: fixed;
  194. bottom: 0;
  195. font-size: 15px;
  196. width: 100%;
  197. height: 65px;
  198. z-index: 20;
  199. background: rgba(0, 0, 0, 0.7);
  200. }
  201. .footer-banner a {
  202. display: block;
  203. color: #cdcdcd;
  204. overflow: hidden;
  205. cursor: pointer;
  206. }
  207. .download-foot {
  208. display: grid;
  209. grid-template-columns: 0.7fr 2fr 1fr 0.3fr;
  210. place-content: space-evenly;
  211. place-items: center;
  212. height: 65px;
  213. }
  214. .download-foot > img {
  215. width: 4rem;
  216. height: 4rem;
  217. }
  218. .download-btn {
  219. width: 25%;
  220. min-width: 80px;
  221. max-width: 200px;
  222. height: 35px;
  223. line-height: 35px;
  224. text-align: center;
  225. border: 1px solid #cdcdcd;
  226. border-radius: 4px;
  227. }

效果图:
效果图

源码下载:
网盘:https://pan.baidu.com/s/1UNhE70XTalQmigPWZ-_NWA
提取码:1234

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