Blogger Information
Blog 9
fans 0
comment 0
visits 6235
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
m.php.cn网站的首页布局(Flex实现-12月27日作业)+PHP培训十期线上班
Original
637 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. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <link rel="stylesheet" href="/public/static/font/iconfont.css">
  8. <link rel="stylesheet" href="../css/mphp.css">
  9. <title>php中文网移动端首页</title>
  10. </head>
  11. <body>
  12. <header>
  13. <a href="">
  14. <img src="../static/images/img1.jpg" alt="头像">
  15. </a>
  16. <img src="../static/images/logo.png" alt="logo">
  17. <em class="iconfont icon-huiyuan2"></em>
  18. </header>
  19. <div class="banner">
  20. <img src="../static/images/img1.jpg" alt="">
  21. </div>
  22. <nav>
  23. <ul>
  24. <li>
  25. <a href="">
  26. <img src="../static/images/img1.jpg" alt="">
  27. <span>我是名字</span>
  28. </a>
  29. </li>
  30. <li>
  31. <a href="">
  32. <img src="../static/images/img1.jpg" alt="">
  33. <span>我是名字</span>
  34. </a>
  35. </li>
  36. <li>
  37. <a href="">
  38. <img src="../static/images/img1.jpg" alt="">
  39. <span>我是名字</span>
  40. </a>
  41. </li>
  42. <li>
  43. <a href="">
  44. <img src="../static/images/img1.jpg" alt="">
  45. <span>我是名字</span>
  46. </a>
  47. </li>
  48. </ul>
  49. <ul>
  50. <li>
  51. <a href="">
  52. <img src="../static/images/img1.jpg" alt="">
  53. <span>我是名字</span>
  54. </a>
  55. </li>
  56. <li>
  57. <a href="">
  58. <img src="../static/images/img1.jpg" alt="">
  59. <span>我是名字</span>
  60. </a>
  61. </li>
  62. <li>
  63. <a href="">
  64. <img src="../static/images/img1.jpg" alt="">
  65. <span>我是名字</span>
  66. </a>
  67. </li>
  68. <li>
  69. <a href="">
  70. <img src="../static/images/img1.jpg" alt="">
  71. <span>我是名字</span>
  72. </a>
  73. </li>
  74. </ul>
  75. </nav>
  76. <main>
  77. <div class="decomment">
  78. <h3>推荐课程</h3>
  79. <div>
  80. <a href=""><img src="../static/images/img1.jpg" alt=""></a>
  81. <a href=""><img src="../static/images/img1.jpg" alt=""></a>
  82. </div>
  83. <ul>
  84. <li>
  85. <a href="">
  86. <img src="../static/images/img1.jpg" alt="">
  87. </a>
  88. <div>
  89. <span>ci框架30分钟极速入门</span>
  90. <span><i>中级</i>555555</span>
  91. </div>
  92. </li>
  93. <li>
  94. <a href="">
  95. <img src="../static/images/img1.jpg" alt="">
  96. </a>
  97. <div>
  98. <span>ci框架30分钟极速入门</span>
  99. <span><i>中级</i>555555</span>
  100. </div>
  101. </li>
  102. </ul>
  103. </div>
  104. <div class="latest">
  105. <h3>最新更新</h3>
  106. <ul>
  107. <li>
  108. <a href="">
  109. <img src="../static/images/img1.jpg" alt="">
  110. </a>
  111. <div>
  112. <span>ci框架30分钟极速入门</span>
  113. <span> 这里是介绍</span>
  114. <span><i>中级</i>555555</span>
  115. </div>
  116. </li>
  117. <li>
  118. <a href="">
  119. <img src="../static/images/img1.jpg" alt="">
  120. </a>
  121. <div>
  122. <span>ci框架30分钟极速入门</span>
  123. <span> 这里是介绍</span>
  124. <span><i>中级</i>555555</span>
  125. </div>
  126. </li>
  127. <li>
  128. <a href="">
  129. <img src="../static/images/img1.jpg" alt="">
  130. </a>
  131. <div>
  132. <span>ci框架30分钟极速入门</span>
  133. <span> 这里是介绍</span>
  134. <span><i>中级</i>555555</span>
  135. </div>
  136. </li>
  137. </ul>
  138. </div>
  139. <div class="article">
  140. <h3>最新文章</h3>
  141. <ul>
  142. <li>
  143. <div>
  144. <a href="">
  145. <span>好多酱油好多酱油</span>
  146. </a>
  147. <span>发布时间</span>
  148. </div>
  149. <a href="">
  150. <img src="../static/images/img1.jpg" alt="">
  151. </a>
  152. </li>
  153. <li>
  154. <div>
  155. <a href="">
  156. <span>好多酱油好多酱油</span>
  157. </a>
  158. <span>发布时间</span>
  159. </div>
  160. <a href="">
  161. <img src="../static/images/img1.jpg" alt="">
  162. </a>
  163. </li>
  164. <li>
  165. <div>
  166. <a href="">
  167. <span>好多酱油好多酱油</span>
  168. </a>
  169. <span>发布时间</span>
  170. </div>
  171. <a href="">
  172. <img src="../static/images/img1.jpg" alt="">
  173. </a>
  174. </li>
  175. </ul>
  176. <button>
  177. 更多内容
  178. </button>
  179. </div>
  180. <div class="bowen">
  181. <h3>博文列表</h3>
  182. <ul>
  183. <li>
  184. <a href="">好好多酱油好多酱油多酱油好多酱油</a>
  185. <span>xxxx-xx-xx</span>
  186. </li>
  187. <li>
  188. <a href="">好好多酱油好多酱油多酱油好多酱油</a>
  189. <span>xxxx-xx-xx</span>
  190. </li>
  191. <li>
  192. <a href="">好好多酱油好多酱油多酱油好多酱油</a>
  193. <span>xxxx-xx-xx</span>
  194. </li> <li>
  195. <a href="">好好多酱油好多酱油多酱油好多酱油</a>
  196. <span>xxxx-xx-xx</span>
  197. </li>
  198. </ul>
  199. <button>
  200. 更多内容
  201. </button>
  202. </div>
  203. <div class="bowen">
  204. <h3>博文列表</h3>
  205. <ul>
  206. <li>
  207. <a href="">好好多酱油好多酱油多酱油好多酱油</a>
  208. <span>xxxx-xx-xx</span>
  209. </li>
  210. <li>
  211. <a href="">好好多酱油好多酱油多酱油好多酱油</a>
  212. <span>xxxx-xx-xx</span>
  213. </li>
  214. <li>
  215. <a href="">好好多酱油好多酱油多酱油好多酱油</a>
  216. <span>xxxx-xx-xx</span>
  217. </li> <li>
  218. <a href="">好好多酱油好多酱油多酱油好多酱油</a>
  219. <span>xxxx-xx-xx</span>
  220. </li>
  221. </ul>
  222. <button class="button">
  223. 更多内容
  224. </button>
  225. </div>
  226. </main>
  227. <footer>
  228. <a href="">
  229. <em class="iconfont icon-icon_fabu"></em>
  230. <span>首页</span>
  231. </a>
  232. <a href="">
  233. <em class="iconfont icon-icon_fabu"></em>
  234. <span>首页</span>
  235. </a>
  236. <a href="">
  237. <em class="iconfont icon-icon_fabu"></em>
  238. <span>首页</span>
  239. </a>
  240. <a href="">
  241. <em class="iconfont icon-icon_fabu"></em>
  242. <span>首页</span>
  243. </a>
  244. </footer>
  245. </body>
  246. </html>

css展示效果

  1. body,footer{
  2. min-width: 360px;
  3. max-width: 768px;
  4. margin: 0 auto;
  5. background-color: #edeff0;
  6. position: relative;
  7. color: gray;
  8. }
  9. body{
  10. border: 1px solid rgb(231, 224, 224);
  11. box-sizing: border-box;
  12. }
  13. img{
  14. width: 100%;
  15. }
  16. ul,li{
  17. margin: 0;
  18. padding: 0;
  19. }
  20. li{
  21. list-style: none;
  22. }
  23. a{
  24. text-decoration: none;
  25. color: gray;
  26. }
  27. header{
  28. position: fixed;
  29. top: 0;
  30. width: 100%;
  31. max-width: 768px;
  32. height: 42px;
  33. background-color: black;
  34. display: flex;
  35. flex-flow: row nowrap;
  36. justify-content: space-between;
  37. align-items: center;
  38. }
  39. header > a > img,
  40. header > em{
  41. width: 26px;
  42. height: 26px;
  43. margin: 7px;
  44. }
  45. header > img{
  46. width: 94px;
  47. }
  48. header > a > img{
  49. border-radius: 50%;
  50. }
  51. .banner{
  52. display: flex;
  53. padding-top: 42px;
  54. height: 200px;
  55. }
  56. /* 导航区 */
  57. nav{
  58. display: flex;
  59. height: 170px;
  60. flex-flow: column nowrap;
  61. background-color: #fff;
  62. padding: 5px;
  63. }
  64. nav > ul{
  65. flex: 1;
  66. display: flex;
  67. flex-flow: row nowrap;
  68. justify-content: space-around;
  69. align-items: center;
  70. }
  71. nav > ul > li > a{
  72. display: flex;
  73. flex-direction: column;
  74. align-items: center;
  75. font-weight: 550;
  76. color: #888;
  77. }
  78. nav > ul > li > a > img{
  79. margin: 5px;
  80. }
  81. nav img{
  82. width: 45px;
  83. height: 49px;
  84. border-radius: 30%;
  85. }
  86. /* main */
  87. main{
  88. display: flex;
  89. flex-direction: column;
  90. margin-top: 10px;
  91. padding: 5px;
  92. }
  93. main > .decomment{
  94. display: flex;
  95. flex-direction: column;
  96. }
  97. h3{
  98. font-size: 18px;
  99. font-weight: bold;
  100. padding-left: 10px;
  101. }
  102. main > .decomment > div{
  103. display: flex;
  104. }
  105. main > .decomment > div > a{
  106. flex-grow: 1;
  107. margin: 0 7px;
  108. }
  109. main > .decomment > div img{
  110. height: 90px;
  111. }
  112. main > .decomment > ul{
  113. display: flex;
  114. flex-direction: column;
  115. margin-top: 10px;
  116. }
  117. main > .decomment > ul li{
  118. display: flex;
  119. background-color: #fff;
  120. margin: 0 7px 10px 7px;
  121. padding: 6px 0 4px 5px;
  122. }
  123. main > .decomment > ul li img{
  124. height: 80px;
  125. }
  126. main > .decomment > ul li > div{
  127. display: flex;
  128. flex-direction: column;
  129. margin-left: 10px;
  130. flex-grow: 1;
  131. }
  132. main > .decomment > ul li > div >span:first-of-type{
  133. font-size: 16.5px;
  134. font-weight: 400;
  135. color: #888
  136. }
  137. main > .decomment > ul li > div >span:last-child{
  138. margin-top: 10px;
  139. font-size: 12px;
  140. }
  141. main > .decomment > ul li > div >span:last-child > i{
  142. background-color: #595757;
  143. font-size: 10px;
  144. border-radius: 20%;
  145. color: seashell;
  146. padding: 3px;
  147. }
  148. /* latest */
  149. main > .latest > div{
  150. display: flex;
  151. }
  152. main > .latest > div > a{
  153. flex-grow: 1;
  154. margin: 0 7px;
  155. }
  156. main > .latest > div img{
  157. height: 90px;
  158. }
  159. main > .latest > ul{
  160. display: flex;
  161. flex-direction: column;
  162. margin-top: 10px;
  163. }
  164. main > .latest > ul li{
  165. display: flex;
  166. background-color: #fff;
  167. margin: 0 7px 10px 7px;
  168. padding: 6px 0 4px 5px;
  169. }
  170. main > .latest > ul li img{
  171. height: 80px;
  172. }
  173. main > .latest > ul li > div{
  174. display: flex;
  175. flex-direction: column;
  176. margin-left: 10px;
  177. flex-grow: 1;
  178. justify-content: space-between;
  179. padding-right: 20px;
  180. }
  181. main > .latest > ul li > div >span{
  182. flex-grow: 1;
  183. }
  184. main > .latest > ul li > div >span:first-of-type{
  185. font-size: 16.5px;
  186. font-weight: 400;
  187. color: #888
  188. }
  189. main > .latest > ul li > div >span:nth-of-type(2){
  190. margin-top: -4px;
  191. font-size: 12px;
  192. }
  193. main > .latest > ul li > div >span:last-child{
  194. display: flex;
  195. line-height: 100%;
  196. font-size: 12px;
  197. justify-content: space-between;
  198. margin-bottom: 3px;
  199. align-items: center;
  200. }
  201. main > .latest > ul li > div >span:last-child > i{
  202. background-color: #595757;
  203. font-size: 10px;
  204. border-radius: 20%;
  205. color: seashell;
  206. padding: 3px;
  207. }
  208. /* article */
  209. main > .article,
  210. main > .article > ul{
  211. display: flex;
  212. flex-direction: column;
  213. }
  214. main > .article > ul li{
  215. display: flex;
  216. background-color: #fff;
  217. margin: 0 7px 10px 7px;
  218. padding: 6px 5px 4px 5px;
  219. }
  220. main > .article > ul li > div{
  221. flex-grow: 1;
  222. margin-right: 10px;
  223. display: flex;
  224. flex-direction: column;
  225. }
  226. main > .article > ul li > div > a{
  227. margin-bottom: 10px;
  228. }
  229. main > .article > ul li > div > a > span{
  230. font-size: 14px;
  231. font-weight: bolder;
  232. }
  233. main > .article > ul li > div > span{
  234. font-size: 12px;
  235. }
  236. main > .article > ul img{
  237. height: 65px;
  238. }
  239. main > .article > button{
  240. border: none;
  241. color: black;
  242. padding: 10px 0;
  243. background-color: #fff;
  244. margin: 0 7px;
  245. margin-bottom: 10px;
  246. }
  247. /* bowen */
  248. main > .bowen{
  249. display: flex;
  250. flex-direction: column;
  251. }
  252. main > .bowen > ul{
  253. display: flex;
  254. flex-direction: column;
  255. margin: 0 7px;
  256. }
  257. main > .bowen > ul > li{
  258. display: flex;
  259. background-color: #fff;
  260. padding: 10px 10px 8px;
  261. margin-bottom: 10px;
  262. justify-content: space-between;
  263. }
  264. main > .bowen > ul > li a{
  265. font-size: 14px;
  266. font-weight: bold;
  267. }
  268. main > .bowen > ul > li > span{
  269. font-size: 12px;
  270. }
  271. main > .bowen > button{
  272. border: none;
  273. color: black;
  274. padding: 10px 0;
  275. background-color: #fff;
  276. margin: 0 7px;
  277. margin-bottom: 10px;
  278. }
  279. .bowen:last-child{
  280. padding-bottom: 51px;
  281. }
  282. /* footer */
  283. footer{
  284. display: flex;
  285. justify-content: space-around;
  286. height: 51px;
  287. border-top: 1px solid burlywood;
  288. align-items: center;
  289. position: fixed;
  290. bottom: 0;
  291. width: 100%;
  292. max-width: 768px;
  293. }
  294. footer > a{
  295. display: flex;
  296. flex-direction: column;
  297. align-items: center;
  298. }
  299. footer > a > em{
  300. font-size: 14px;
  301. }
  302. footer > a > span{
  303. font-size: 14px;
  304. margin-top: 2px;
  305. }

总结

在没有看老师讲的之前,自己动手试了做了一下,结果心有余力不足。 总结一下几点:
首先理清DOM结构
理清DOM结构之后,css设置一些全局配置,给后续做铺垫
参照m.php.cn 上DOM的结构尺寸进行布局
看了一遍视频,理清思路,虽然写的有点吃力,但是还好出来一个样子。(附上一个链接:我的作品
还请老师指点一下不足、和错误。 下次改正!

Correcting teacher:天蓬老师天蓬老师

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