Blogger Information
Blog 19
fans 1
comment 0
visits 13301
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
flex布局仿站实战--php培训第九期线上班
涤尘
Original
539 people have browsed it
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>php中文网手机版首页</title>
  6. <link rel="stylesheet" href="static/css/init.css">
  7. <link rel="stylesheet" href="static/css/style.css">
  8. </head>
  9. <body>
  10. <!--布局原则: 宽度自适应,高度固定-->
  11. <!--顶部固定定位-->
  12. <header>
  13. <img src="static/images/user-pic.jpeg" alt="">
  14. <img src="static/images/logo.png" alt="">
  15. <img src="static/images/user-nav.jpg" alt="">
  16. </header>
  17. <!--banner轮播图,这里用图片暂时代替-->
  18. <div class="banner">
  19. <img src="static/images/banner.jpg" alt="">
  20. </div>
  21. <!--导航区-->
  22. <nav>
  23. <ul>
  24. <li>
  25. <a href="">
  26. <img src="static/images/html.png" alt="">
  27. <span>HTML/CSS</span>
  28. </a>
  29. </li>
  30. <li>
  31. <a href="">
  32. <img src="static/images/JavaScript.png" alt="">
  33. <span>JavaScript</span>
  34. </a>
  35. </li>
  36. <li>
  37. <a href="">
  38. <img src="static/images/code.png" alt="">
  39. <span>服务端</span>
  40. </a>
  41. </li>
  42. <li>
  43. <a href="">
  44. <img src="static/images/sql.png" alt="">
  45. <span>数据库</span>
  46. </a>
  47. </li>
  48. </ul>
  49. <ul>
  50. <li>
  51. <a href=""><img src="static/images/app.png" alt="">
  52. <span>移动端</span>
  53. </a>
  54. </li>
  55. <li>
  56. <a href="">
  57. <img src="static/images/manual.png" alt="">
  58. <span>手册</span>
  59. </a>
  60. </li>
  61. <li>
  62. <a href=""><img src="static/images/tool2.png" alt="">
  63. <span>工具</span>
  64. </a>
  65. </li>
  66. <li>
  67. <a href="">
  68. <img src="static/images/live.png" alt="">
  69. <span>直播</span>
  70. </a>
  71. </li>
  72. </ul>
  73. </nav>
  74. <!-- 课程区-->
  75. <main>
  76. <!-- 推荐课程-->
  77. <article class="recommend">
  78. <h3>推荐课程</h3>
  79. <section>
  80. <a href=""><img src="static/images/tjkc1.jpg" alt=""></a>
  81. <a href=""><img src="static/images/tjkc2.jpg" alt=""></a>
  82. </section>
  83. <section>
  84. <div>
  85. <a href=""><img src="static/images/tjkc3.jpg" alt=""></a>
  86. <span>
  87. <a href="">CI框架30分钟极速入门</a>
  88. <span><i>中级</i>49738次播放</span>
  89. </span>
  90. </div>
  91. <div>
  92. <a href=""><img src="static/images/tjkc4.jpg" alt=""></a>
  93. <span>
  94. <a href="">2018前端入门基础</a>
  95. <span><i>初级</i>209952次播放</span>
  96. </span>
  97. </div>
  98. </section>
  99. </article>
  100. <!--最新更新-->
  101. <article class="recommend-1">
  102. <h3>最新更新</h3>
  103. <section>
  104. <div>
  105. <a href=""><img src="static/images/zx1.jpg" alt=""></a>
  106. <span>
  107. <a href="">2019python自学视频</a>
  108. <p>本课程适合想从零开始学习 Python 编程语言的开发人员。由浅入深的带你进...</p>
  109. <span><i>初级</i>1657次播放</span>
  110. </span>
  111. </div>
  112. <div>
  113. <a href=""><img src="static/images/zx2.png" alt=""></a>
  114. <span>
  115. <a href="">PHP开发免费公益直播课</a>
  116. <p>主讲:php中文网-朱老师( Peter Zhu) 时间:2019.10.17 晚 20:00-22:00...</p>
  117. <span><i>初级</i>1818次播放</span>
  118. </span>
  119. </div>
  120. <div>
  121. <a href=""><img src="static/images/zx3.jpg" alt=""></a>
  122. <span>
  123. <a href="">从零开始到WEB响应式布局</a>
  124. <p>主重点介绍了HTML、CSS、web布局前端核心技术,通过视频讲解,了解...</p>
  125. <span><i>初级</i>3119次播放</span>
  126. </span>
  127. </div>
  128. <div>
  129. <a href=""><img src="static/images/zx4.png" alt=""></a>
  130. <span>
  131. <a href="">PHP文件基础操作</a>
  132. <p>好多同学在PHP基础的时候对PHP文件的操作了解的不够多,本节课就带...</p>
  133. <span><i>初级</i>1644次播放</span>
  134. </span>
  135. </div>
  136. <div>
  137. <a href=""><img src="static/images/zx5.jpg" alt=""></a>
  138. <span>
  139. <a href="">memcache基础课程</a>
  140. <p>本课程带你从零认识memcache,让你在一小时左右轻松掌握memcache...</p>
  141. <span><i>初级</i>782次播放</span>
  142. </span>
  143. </div>
  144. <div>
  145. <a href=""><img src="static/images/zx6.png" alt=""></a>
  146. <span>
  147. <a href="">微信小程序--企业微网站</a>
  148. <p>1,介绍小程序、开发者工具 2,介绍小程序文档 3,微官网项目 4,首页...</p>
  149. <span><i>初级</i>3508次播放</span>
  150. </span>
  151. </div>
  152. </section>
  153. </article>
  154. <!--最新文章-->
  155. <article class="recommend-2">
  156. <h3>最新文章</h3>
  157. <section>
  158. <a href="">
  159. <img src="static/images/wz1.jpg" alt="">
  160. <span>
  161. <span>重启阿里云ECS服务器实例</span>
  162. <p>发布时间:2019-11-07</p>
  163. </span>
  164. </a>
  165. <a href="">
  166. <img src="static/images/wz2.jpg" alt="">
  167. <span>
  168. <span>重启阿里云ECS服务器实例</span>
  169. <p>发布时间:2019-11-07</p>
  170. </span>
  171. </a>
  172. <a href="">
  173. <img src="static/images/wz3.jpg" alt="">
  174. <span>
  175. <span>重启阿里云ECS服务器实例</span>
  176. <p>发布时间:2019-11-07</p>
  177. </span>
  178. </a>
  179. <a href="">
  180. <img src="static/images/wz4.jpg" alt="">
  181. <span>
  182. <span>重启阿里云ECS服务器实例</span>
  183. <p>发布时间:2019-11-07</p>
  184. </span>
  185. </a>
  186. <a href="""><div><span>更多内容</span></div></a>
  187. </section>
  188. </article>
  189. <!-- 最新博文 -->
  190. <article class="recommend-3">
  191. <h3>最新博文</h3>
  192. <section>
  193. <a href="">
  194. <div>
  195. <h5>PHP学习第一天:软件安装篇</h5>
  196. <span>2019-11-08</span>
  197. </div>
  198. </a>
  199. <a href="">
  200. <div>
  201. <h5>Linux系统CentOS报错:could not resolve host:mirrorlist.centos.org问题</h5>
  202. <span>2019-11-08</span>
  203. </div>
  204. </a>
  205. <a href="">
  206. <div>
  207. <h5>thinkphp5.0.24前置操作的大小写问题</h5>
  208. <span>2019-11-08</span>
  209. </div>
  210. </a>
  211. <a href="">
  212. <div>
  213. <h5>laravel-创建“控制器”和“模型”,使用模型方法获取数据库内容并输出--2019</h5>
  214. <span>2019-11-08</span>
  215. </div>
  216. </a>
  217. <a href="">
  218. <div>
  219. <h5>MVC模式的工作原理--2019年10月31日</h5>
  220. <span>2019-11-08</span>
  221. </div>
  222. </a>
  223. <a href="">
  224. <div>
  225. <div>
  226. <span>更多内容</span>
  227. </div>
  228. </div>
  229. </a>
  230. </section>
  231. </article>
  232. <!-- 最新问答 -->
  233. <article class="recommend-3">
  234. <h3>最新问答</h3>
  235. <section>
  236. <a href="">
  237. <div>
  238. <h5>为什么我的 Mac电脑用 safari看PHP中文网 视频都看不了</h5>
  239. <span>2019-11-08</span>
  240. </div>
  241. </a>
  242. <a href="">
  243. <div>
  244. <h5>我写的哪里有错?请大神帮忙查看一下。</h5>
  245. <span>2019-11-08</span>
  246. </div>
  247. </a>
  248. <a href="">
  249. <div>
  250. <h5>html翻译环境</h5>
  251. <span>2019-11-08</span>
  252. </div>
  253. </a>
  254. <a href="">
  255. <div>
  256. <h5>sublimetext不可以开发这个吗</h5>
  257. <span>2019-11-08</span>
  258. </div>
  259. </a>
  260. <a href="">
  261. <div>
  262. <h5>css伪类选择器怎么插入图片</h5>
  263. <span>2019-11-08</span>
  264. </div>
  265. </a>
  266. <a href="">
  267. <div>
  268. <div>
  269. <span>更多内容</span>
  270. </div>
  271. </div>
  272. </a>
  273. </section>
  274. </article>
  275. </main>
  276. <!--底部-->
  277. <footer>
  278. <a href=""><img src="static/font-icon/zhuye.png" alt="">
  279. <span>主页</span></a>
  280. <a href="">
  281. <img src="static/font-icon/video.png" alt="">
  282. <span>视频</span>
  283. </a>
  284. <a href="">
  285. <img src="static/font-icon/luntan.png" alt="">
  286. <span>社区</span>
  287. </a>
  288. <a href="">
  289. <img src="static/font-icon/geren.png" alt="">
  290. <span>我的</span>
  291. </a>
  292. </footer>
  293. </body>
  294. </html>
  1. /*************** 头部样式 ***************/
  2. header {
  3. /*固定定位*/
  4. position: fixed;
  5. top: 0;
  6. /*固定定位元素必须设置宽度与高度*/
  7. width: 100%;
  8. height: 42px;
  9. background: #444444;
  10. color: white;
  11. /*设置最小尺寸*/
  12. min-width: 320px;
  13. max-width: 768px;
  14. /*转为Flex容器,设置元素排列*/
  15. display: flex;
  16. /*元素主轴分散,两端对齐*/
  17. justify-content: space-between;
  18. /*元素交叉轴居中对齐*/
  19. align-items: center;
  20. }
  21. /*第一张,最后一设置通用样式*/
  22. header > img:first-of-type,
  23. header > img:last-of-type {
  24. width: 26px;
  25. height: 26px;
  26. margin: 5px;
  27. }
  28. /*第一张用户头像应该是正圆*/
  29. header > img:first-of-type {
  30. border-radius: 50%; /* 13px */
  31. }
  32. /*设置中间LOGO样式*/
  33. header > img {
  34. width: 94px;
  35. }
  36. /*************** 轮播图设置 ***************/
  37. .banner {
  38. display: flex;
  39. height: 200px;
  40. }
  41. /*************** 导航区 ***************/
  42. nav {
  43. background-color: white;
  44. display: flex;
  45. /*主轴为垂直方向, 禁止换行*/
  46. flex-flow: column nowrap;
  47. }
  48. /*图片默认大小*/
  49. nav img {
  50. width: 45px;
  51. height: 49px;
  52. }
  53. /*每一行导航都应该是一个弹性容器以方便布局*/
  54. nav > ul {
  55. display: flex;
  56. /*每个菜单项水平且不换行*/
  57. flex-flow: row nowrap;
  58. }
  59. /*每一菜单项均分全部空间*/
  60. nav ul li {
  61. flex: 1;
  62. }
  63. /*图片与文本应该做为一个组件,统一设置*/
  64. nav ul li a {
  65. display: flex;
  66. /*图片, 链接文本垂直排列*/
  67. flex-flow: column wrap;
  68. /*交叉轴上居中显示*/
  69. align-items: center;
  70. /*外边距可以使菜单项之间不太拥挤*/
  71. margin: 10px;
  72. }
  73. /*菜单项文本与上面图标有一个间隙*/
  74. nav ul li a span {
  75. margin-top: 5px;
  76. }
  77. /*************** 主体内容区 ***************/
  78. /******** 推荐课程区 *******/
  79. main {
  80. display: flex;
  81. flex-flow: column nowrap;
  82. }
  83. /*设置水平排列的推荐课程*/
  84. main > .recommend > section:first-of-type {
  85. display: flex;
  86. flex-flow: row nowrap;
  87. }
  88. /*每个课程图片平分全部空间*/
  89. main > .recommend > section:first-of-type > a {
  90. margin: 5px;
  91. flex: 1;
  92. }
  93. /*设置图片高度*/
  94. main > .recommend > section:first-of-type > a > img {
  95. height: 90px;
  96. }
  97. /*设置垂直排列的推荐课程*/
  98. main > .recommend > section:last-of-type {
  99. display: flex;
  100. flex-flow: column nowrap;
  101. }
  102. main > .recommend > section:last-of-type > div {
  103. background-color: #fff;
  104. margin: 5px;
  105. /*也转为弹性容器*/
  106. display: flex;
  107. flex-flow: row nowrap;
  108. }
  109. main > .recommend > section:last-of-type > div img {
  110. width: 350px;
  111. height: 90px;
  112. }
  113. main > .recommend > section:last-of-type > div > span {
  114. display: flex;
  115. /*文本垂直排列*/
  116. flex-flow: column nowrap;
  117. margin-top: 5px;
  118. padding-left: 10px;
  119. }
  120. main > .recommend > section:last-of-type > div > span i {
  121. font-style: normal;
  122. background-color: #333333;
  123. color: white;
  124. border-radius: 4px;
  125. padding: 0 5px;
  126. font-size: smaller;
  127. }
  128. /*最新更新*/
  129. main > .recommend-1 > section {
  130. display: flex;
  131. flex-flow: column nowrap;
  132. }
  133. main > .recommend-1 > section > div {
  134. background-color: #fff;
  135. margin: 5px;
  136. /*也转为弹性容器*/
  137. display: flex;
  138. flex-flow: row nowrap;
  139. }
  140. main > .recommend-1 > section > div img {
  141. width: 350px;
  142. height: 90px;
  143. }
  144. main > .recommend-1 > section > div > span {
  145. display: flex;
  146. /*文本垂直排列*/
  147. flex-flow: column nowrap;
  148. margin-top: 5px;
  149. padding-left: 10px;
  150. padding-right: 15px;
  151. }
  152. main > .recommend-1 > section > div > span > p {
  153. font-size: 1px;
  154. }
  155. main > .recommend-1 > section > div > span > span {
  156. display: flex;
  157. justify-content: space-between;
  158. font-size: smaller;
  159. }
  160. main > .recommend-1 > section > div > span i {
  161. font-style: normal;
  162. background-color: #333333;
  163. color: white;
  164. border-radius: 8px;
  165. padding: 0 5px;
  166. }
  167. /*最新文章*/
  168. main > .recommend-2 > section {
  169. display: flex;
  170. flex-flow: column nowrap;
  171. }
  172. main > .recommend-2 > section > a{
  173. background-color: #fff;
  174. margin: 5px;
  175. display: flex;
  176. flex-flow: row-reverse nowrap;
  177. }
  178. main > .recommend-2 > section > a >img {
  179. width: 220px;
  180. height: 70px;
  181. margin-top: 5px;
  182. margin-bottom: 5px;
  183. margin-right: 5px;
  184. }
  185. main > .recommend-2 > section > a > span {
  186. display: flex;
  187. /*文本垂直排列*/
  188. flex-flow: column nowrap;
  189. position: relative;
  190. left: -48%;
  191. margin-top: 10px;
  192. }
  193. main > .recommend-2 > section > a > span > p {
  194. font-size: 1px;
  195. }
  196. main > .recommend-2 > section > a > span > span {
  197. font-size: smaller;
  198. }
  199. main > .recommend-2 > section > a:last-of-type > div {
  200. display: flex;
  201. align-items: center;
  202. justify-content: center;
  203. flex: 1;
  204. height: 50px;
  205. }
  206. /*最新博文*/
  207. main >.recommend-3 > section > a > div {
  208. display: flex;
  209. flex-flow: row nowrap;
  210. justify-content: space-between;
  211. background-color: white;
  212. height: 50px;
  213. margin-top: 10px;
  214. }
  215. main >.recommend-3 > section > a > div > span {
  216. padding: 10px 5px;
  217. font-size: 1px;
  218. }
  219. main >.recommend-3 > section > a > div > h5 {
  220. margin-left: 10px;
  221. margin-top: 8px;
  222. }
  223. main >.recommend-3 > section > a > div > div {
  224. display: flex;
  225. align-items: center;
  226. justify-content: center;
  227. flex: 1;
  228. }
  229. /*底部*/
  230. footer {
  231. /*固定定位*/
  232. position: fixed;
  233. bottom: 0;
  234. border-top: 1px solid #BBBBBB;
  235. /*固定定位元素必须设置宽度与高度*/
  236. width: 100%;
  237. height: 42px;
  238. background: #EEEEEE;
  239. color: white;
  240. /*转为Flex容器,设置元素排列*/
  241. display: flex;
  242. /*元素主轴分散,两端平均对齐*/
  243. justify-content: space-around;
  244. /*元素交叉轴居中对齐*/
  245. align-items: center;
  246. }
  247. footer > a > img {
  248. height: 16px;
  249. width: 16px;
  250. }
  251. footer > a {
  252. display: flex;
  253. flex-flow: column wrap;
  254. align-items: center;
  255. }




总结:

通过对flex布局实战的练习,发现了很多问题,第一点:脑子中有思路,就是做的时候不知道怎么写,这应该是基础知识不太牢固,第二点:关于布局时候,最好先画给草图,了解先后顺序,这样在做容器嵌套不至于乱,第三点:关于容器的直接子元素问题,一定要是其直接子元素,否则无效,被坑过多次!关于老师讲的很多知识点在实际开发中,有些用不到,但要知道,说不准什么时间就要用到了!总之还是要多写 多练 多踩坑,不要走冤路!通过对flex布局实战的练习,发现了很多问题,第一点:脑子中有思路,就是做的时候不知道怎么写,这应该是基础知识不太牢固,第二点:关于布局时候,最好先画给草图,了解先后顺序,这样在做容器嵌套不至于乱,第三点:关于容器的直接子元素问题,一定要是其直接子元素,否则无效,被坑过多次!关于老师讲的很多知识点在实际开发中,有些用不到,但要知道,说不准什么时间就要用到了!总之还是要多写 多练 多踩坑,不要走冤路!



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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!