Blogger Information
Blog 22
fans 1
comment 0
visits 17829
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
第十期FLEX防PHP中文网移动端首页布局(2019-12-27)
齐齐
Original
563 people have browsed it

PHP中文网首页

首先打开网页m.php.cn对网页结构进行布局分页,整体分为三大部分,头部,主体,和底部。

头部部分,采用左中右。使用两端对齐,实现展示效果。主体部分,幻灯采用一张图片。导航栏分为2个ul垂直排列,然后再对里面的li进行水平平均对齐。

推荐课程分为三部分,上中下,中间部分是为2张可点击的图片,水平排列在一起。图文列表采用左右排列,然后再对右侧进行划分,进行垂直排列。最新更新类似推荐课程图文部分,只是改变左右项目order值。

底部为分为四分,水平排列,再对里面的flex项目进行垂直排列对齐。

页面的主要html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>php中文网手机首页</title>
  6. <style>
  7. /*样式初始化*/
  8. *:not(body){
  9. padding:0;
  10. margin: 0;
  11. font-size: 13px;
  12. }
  13. i{font-style: normal}
  14. ul,li{list-style: none;}
  15. a{text-decoration:none;color:#777}
  16. img{width:100%;}
  17. body{
  18. display: flex;
  19. flex-direction: column;
  20. min-width: 320px;
  21. max-width: 640px;
  22. background-color: #edeff0;
  23. margin: auto;
  24. color: #888;
  25. }
  26. /*网站头部*/
  27. body > header{
  28. padding: 0 5px;
  29. box-sizing: border-box;
  30. display: flex;
  31. background:#2d353c;
  32. justify-content: space-between;
  33. align-items: center;
  34. height: 6vh;
  35. position: fixed;
  36. width: 100vw;
  37. margin-bottom: 6vh;
  38. }
  39. body > header img{
  40. width: 26px;
  41. }
  42. body > header > :nth-child(2) img{
  43. width: 70px;}
  44. body > header > a:first-child img{border-radius: 50%;}
  45. /*主体部分*/
  46. body > main{
  47. display: flex;
  48. flex-direction: column;
  49. }
  50. /*导航区*/
  51. body > main > nav{
  52. display: flex;
  53. flex-direction: column;
  54. background: #fff;
  55. }
  56. body > main > nav >ul{
  57. display: flex;
  58. justify-content: space-evenly;
  59. }
  60. body > main > nav >ul >li{
  61. flex: 1;
  62. }
  63. body > main > nav >ul >li img{
  64. width: 45px;
  65. height: 49px;
  66. margin-bottom: 10px;
  67. }
  68. body > main > nav >ul >li >a{
  69. margin: 8px;
  70. display: flex;
  71. flex-direction: column;
  72. align-items: center;
  73. }
  74. /*推荐课程*/
  75. main > section{
  76. display: flex;
  77. flex-direction: column;
  78. padding: 5px;
  79. }
  80. main > section > h3{font-size: 20px;margin: 10px 0;color: #888}
  81. main > section > div{
  82. display: flex;
  83. justify-content: space-between;
  84. }
  85. main > section > div a{
  86. width: 49%;
  87. }
  88. main > section > div a img{
  89. height: 100px;}
  90. main > section > article{
  91. display: flex;
  92. padding: 8px;
  93. background: #fff;
  94. justify-content: space-between;
  95. margin-bottom: 10px;
  96. }
  97. main > section > article > img {width:35%;height: 80px;
  98. }
  99. main > section > article > div{
  100. display: flex;
  101. flex-direction: column;
  102. flex: 0.98;
  103. justify-content: space-around;
  104. }
  105. main > section > article > div >p{font-size:11px}
  106. main > section > article > div >a {font-size: 15px}
  107. main > section > article > div i{font-size:11px;font-style: normal;background:#595757;border-radius: 3px;padding: 0 5px;color:#fff;margin-right: 8px;}
  108. main > section > article > div >div{
  109. display: flex;
  110. justify-content: space-between;
  111. }
  112. /*最新文章*/
  113. main > section:nth-of-type(4) img{ order: 3;height: 60px;}
  114. main > section:nth-of-type(4) div{ order: 2}
  115. main > section:nth-of-type(4) div a{font-weight:700;font-size: 13px;}
  116. main > section >a{background: #fff;text-align: center;padding: 3px 0}
  117. /*最新博文*/
  118. main > section:nth-of-type(5)>article >a,main > section:nth-of-type(6)>article >a{
  119. flex: auto;
  120. display: flex;
  121. justify-content: space-between;
  122. }
  123. main > section:last-of-type> a:last-of-type{margin-bottom: 50px;}
  124. /*网站底部*/
  125. footer{
  126. display: flex;
  127. background: #edeff0;
  128. border-top: 1px solid #ccc;
  129. margin-top: 10px;
  130. position: fixed;
  131. bottom: 0;
  132. width: 100vw;
  133. }
  134. footer>a>img{width: 20px;padding: 6px 0}
  135. footer>a{
  136. display: flex;
  137. flex-direction: column;
  138. flex: auto;
  139. justify-content:space-evenly;
  140. align-items: center;
  141. }
  142. </style>
  143. </head>
  144. <body>
  145. <header>
  146. <a href=""><img src="static/images/user-pic.jpeg" alt=""></a>
  147. <a href="" class="logo"><img src="static/images/logo.png" alt=""></a>
  148. <img src="static/images/user-nav.jpg" alt="">
  149. </header>
  150. <main>
  151. <header><a href=""><img src="static/images/banner.jpg" alt=""></a></header>
  152. <nav>
  153. <ul>
  154. <li><a href=""><img src="static/images/html.png"><span>HTML/CSS</span></a></li>
  155. <li><a href=""><img src="static/images/JavaScript.png"><span>JavaScript</span></a></li>
  156. <li><a href=""><img src="static/images/code.png"><span>服务端</span></a></li>
  157. <li><a href=""><img src="static/images/sql.png"><span>数据库</span></a></li>
  158. </ul>
  159. <ul>
  160. <li><a href=""><img src="static/images/html.png"><span>HTML/CSS</span></a></li>
  161. <li><a href=""><img src="static/images/JavaScript.png"><span>JavaScript</span></a></li>
  162. <li><a href=""><img src="static/images/code.png"><span>服务端</span></a></li>
  163. <li><a href=""><img src="static/images/sql.png"><span>数据库</span></a></li>
  164. </ul>
  165. </nav>
  166. <section>
  167. <h3>推荐课程</h3>
  168. <div>
  169. <a href=""><img src="static/images/tjkc1.jpg" alt=""></a>
  170. <a href=""><img src="static/images/tjkc2.jpg" alt=""></a>
  171. </div>
  172. </section>
  173. <section>
  174. <article>
  175. <img src="static/images/tjkc3.jpg" alt="">
  176. <div>
  177. <a href="">CI框架30分钟极速入门</a>
  178. <span><i>中级</i>55749次播放</span>
  179. </div>
  180. </article>
  181. <article>
  182. <img src="static/images/tjkc4.jpg" alt="">
  183. <div>
  184. <a href="">2019前端入门_HTML5</a>
  185. <span><i>初级</i>557925次播放</span>
  186. </div>
  187. </article>
  188. </section>
  189. <section>
  190. <h3>最新更新</h3>
  191. <article>
  192. <img src="static/images/tjkc3.jpg" alt="">
  193. <div>
  194. <a href="">2019python自学视频</a>
  195. <p>本课程适合想从零开始学习 Python 编程语言的开发人员。由浅。。。</p>
  196. <div><i>初级</i><span>12702次播放</span></div>
  197. </div>
  198. </article>
  199. <article>
  200. <img src="static/images/tjkc4.jpg" alt="">
  201. <div>
  202. <a href="">PHP开发免费公益直播课</a>
  203. <p>本课程适合想从零开始学习 Python 编程语言的开发人员。你进入pyt。。。</p>
  204. <div><i>初级</i><span>3749次播放</span></div>
  205. </div>
  206. </article>
  207. <article>
  208. <img src="static/images/tjkc3.jpg" alt="">
  209. <div>
  210. <a href="">2019python自学视频</a>
  211. <p>本课程适合想从零开始学习 开发人员。由浅入深的带你进入pyt。。。</p>
  212. <div><i>初级</i><span>12702次播放</span></div>
  213. </div>
  214. </article>
  215. <article>
  216. <img src="static/images/tjkc4.jpg" alt="">
  217. <div>
  218. <a href="">PHP开发免费公益直播课</a>
  219. <p>本课程适合想从零开始学习 P语言的开发人员。由浅入深的带你进入pyt。。。</p>
  220. <div><i>初级</i><span>3749次播放</span></div>
  221. </div>
  222. </article>
  223. </section>
  224. <section>
  225. <h3>最新文章</h3>
  226. <article>
  227. <img src="static/images/wz.jpg" alt="">
  228. <div>
  229. <a href="">PHP 闭包之变量作用域</a>
  230. <span>发布时间:2019-12-30</span>
  231. </div>
  232. </article>
  233. <article>
  234. <img src="static/images/tjkc4.jpg" alt="">
  235. <div>
  236. <a href="">vscode中无法使用npm命令</a>
  237. <span>发布时间:2019-12-30</span>
  238. </div>
  239. </article>
  240. <article>
  241. <img src="static/images/wz.jpg" alt="">
  242. <div>
  243. <a href="">PHP 闭包之变量作用域</a>
  244. <span>发布时间:2019-12-30</span>
  245. </div>
  246. </article>
  247. <article>
  248. <img src="static/images/tjkc4.jpg" alt="">
  249. <div>
  250. <a href="">vscode中无法使用npm命令</a>
  251. <span>发布时间:2019-12-30</span>
  252. </div>
  253. </article>
  254. <a href="">更多内容</a>
  255. </section>
  256. <section>
  257. <h3>最新博文</h3>
  258. <article>
  259. <a href="">
  260. <span>composer安装laravel,nginx服务器路配置解决404问题,创建简单的控制器</span>
  261. <i>2019-12-27</i>
  262. </a>
  263. </article>
  264. <article>
  265. <a href="">
  266. <span>转载《PHP安全之道》学习笔记1:PHP项目安全设置</span>
  267. <i>2019-12-25</i>
  268. </a>
  269. </article>
  270. <article>
  271. <a href="">
  272. <span>composer安装laravel,nginx服务器路配置解决404问题,创建简单的控制器</span>
  273. <i>2019-12-27</i>
  274. </a>
  275. </article>
  276. <article>
  277. <a href="">
  278. <span>转载《PHP安全之道》学习笔记1:PHP项目安全设置</span>
  279. <i>2019-12-25</i>
  280. </a>
  281. </article>
  282. <a href="">更多内容</a>
  283. </section>
  284. <section>
  285. <h3>最新问答</h3>
  286. <article>
  287. <a href="">
  288. <span>thinkphp5.1学习时遇到session问题</span>
  289. <i>2019-12-27</i>
  290. </a>
  291. </article>
  292. <article>
  293. <a href="">
  294. <span>提交之后显示PHP代码</span>
  295. <i>2019-12-25</i>
  296. </a>
  297. </article>
  298. <article>
  299. <a href="">
  300. <span>thinkphp5.1学习时遇到session问题</span>
  301. <i>2019-12-27</i>
  302. </a>
  303. </article>
  304. <article>
  305. <a href="">
  306. <span>提交之后显示PHP代码</span>
  307. <i>2019-12-25</i>
  308. </a>
  309. </article>
  310. <a href="">更多内容</a>
  311. </section>
  312. </main>
  313. <footer>
  314. <a href=""><img src="static/font-icon/zhuye.png" alt=""><span>主页</span></a>
  315. <a href=""><img src="static/font-icon/video.png" alt=""><span>视频</span></a>
  316. <a href=""><img src="static/font-icon/luntan.png" alt=""><span>社区</span></a>
  317. <a href=""><img src="static/font-icon/geren.png" alt=""><span>我的</span></a>
  318. </footer>
  319. </body>
  320. </html>

页面的运行整个效果图

总结:flex成功干掉浮动元素,但是使用上还是会经常犯糊涂。代码中直接用选择器来实现,会在选择元素上出现一点问题。flex弹性布局,动手起来并没有想的那么简单。只有不断的练习中,才能轻松自如的驾驭。flex容器属性和flex项目属性知识掌握,才是学好flex至关重要的第一步。

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