博客列表 >php中文手机网布局-php培训线上九期班

php中文手机网布局-php培训线上九期班

邯郸易住宋至刚
邯郸易住宋至刚原创
2019年11月16日 23:55:33827浏览

PHP中文网手机端首页

HTML代码:

  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. <!--可以直接复制推荐课程的代码, 只需要将内容和素材换一下即可-->
  102. <article class="update">
  103. <h3>最新更新</h3>
  104. <section>
  105. <div>
  106. <a href=""><img src="static/images/5db2b53c67bca626.jpg" alt=""></a>
  107. <span>
  108. <a href="">2019python自学视频</a>
  109. <span><i>中级</i>49738次播放</span>
  110. </span>
  111. </div>
  112. <div>
  113. <a href=""><img src="static/images/5da7e9b7895ed229.png" alt=""></a>
  114. <span>
  115. <a href="">PHP开发免费公益直播课</a>
  116. <span><i>初级</i>209952次播放</span>
  117. </span>
  118. </div>
  119. <div>
  120. <a href=""><img src="static/images/5da6a50535529903.jpg" alt=""></a>
  121. <span>
  122. <a href="">从零开始到WEB响应式布局</a>
  123. <span><i>中级</i>49738次播放</span>
  124. </span>
  125. </div>
  126. <div>
  127. <a href=""><img src="static/images/5da51b8ff1224244.png" alt=""></a>
  128. <span>
  129. <a href="">PHP文件基础操作</a>
  130. <span><i>初级</i>209952次播放</span>
  131. </span>
  132. </div>
  133. <div>
  134. <a href=""><img src="static/images/5da16c1d7f658408.jpg" alt=""></a>
  135. <span>
  136. <a href="">memcache基础课程</a>
  137. <span><i>中级</i>49738次播放</span>
  138. </span>
  139. </div>
  140. <div>
  141. <a href=""><img src="static/images/5d9ec555ee63b448.png" alt=""></a>
  142. <span>
  143. <a href="">微信小程序--企业微网站</a>
  144. <span><i>初级</i>209952次播放</span>
  145. </span>
  146. </div>
  147. </section>
  148. </article>
  149. <!--最新文章-->
  150. <!--这个模块与上面的最新课程几乎是一样的, 只是左右顺序交换了一个,样式略有不同-->
  151. <article class="wenzhang">
  152. <h3>最新文章</h3>
  153. <section>
  154. <div>
  155. <span>
  156. <a href="">php常量存储的数据只能是哪些数据类型</a>
  157. <span>发布时间:2019-11-16</span>
  158. </span>
  159. <a href=""><img src="static/images/5dcfbc87dccc4570.jpg" alt=""></a>
  160. </div>
  161. <div>
  162. <span>
  163. <a href="">php怎么将字符串炸开</a>
  164. <span>发布时间:2019-11-16</span>
  165. </span>
  166. <a href=""><img src="static/images/5dcfbc22304e6935.jpg" alt=""></a>
  167. </div>
  168. <div>
  169. <span>
  170. <a href="">从零开始到WEB响应式布局</a>
  171. <span>发布时间:2019-11-16</span>
  172. </span>
  173. <a href=""><img src="static/images/5dcfc9e482387681.jpg" alt=""></a>
  174. </div>
  175. <div>
  176. <span>
  177. <a href="">PHP文件基础操作</a>
  178. <span>发布时间:2019-11-16</span>
  179. </span>
  180. <a href=""><img src="static/images/5dcfc8e9d352e924.jpg" alt=""></a>
  181. </div>
  182. <div>
  183. <span>
  184. <a href="">memcache基础课程</a>
  185. <span>发布时间:2019-11-16</span>
  186. </span>
  187. <a href=""><img src="static/images/5d8ad5d450899652.jpg" alt=""></a>
  188. </div>
  189. </section>
  190. </article>
  191. <!-- 最新博文,最新问答,做为作业,交给大家课后完成 -->
  192. <article class="blog">
  193. <h3>最新博文</h3>
  194. <section>
  195. <div>
  196. <a href="">2019python自学视频</a>
  197. <span>2019-11-16</span>
  198. </div>
  199. <div>
  200. <a href="">PHP开发免费公益直播课</a>
  201. <span>2019-11-16</span>
  202. </div>
  203. <div>
  204. <a href="">从零开始到WEB响应式布局</a>
  205. <span>2019-11-16</span>
  206. </div>
  207. <div>
  208. <a href="">PHP文件基础操作</a>
  209. <span>2019-11-16</span>
  210. </div>
  211. <div>
  212. <a href="">memcache基础课程</a>
  213. <span>2019-11-16</span>
  214. </div>
  215. </section>
  216. </article>
  217. <article class="ask">
  218. <h3>最新问答</h3>
  219. <section>
  220. <div>
  221. <a href="">2019python自学视频</a>
  222. <span>2019-11-16</span>
  223. </div>
  224. <div>
  225. <a href="">PHP开发免费公益直播课</a>
  226. <span>2019-11-16</span>
  227. </div>
  228. <div>
  229. <a href="">从零开始到WEB响应式布局</a>
  230. <span>2019-11-16</span>
  231. </div>
  232. <div>
  233. <a href="">PHP文件基础操作</a>
  234. <span>2019-11-16</span>
  235. </div>
  236. <div>
  237. <a href="">memcache基础课程</a>
  238. <span>2019-11-16</span>
  239. </div>
  240. </section>
  241. </article>
  242. </main>
  243. <!--下面咱们做一下底部,底部与头部类似,也是固定定位实现-->
  244. <footer>
  245. <a href=""><img src="static/font-icon/zhuye.png" alt=""><span>主页</span></a>
  246. <a href="">
  247. <img src="static/font-icon/video.png" alt="">
  248. <span>视频</span>
  249. </a>
  250. <a href="">
  251. <img src="static/font-icon/luntan.png" alt="">
  252. <span>社区</span>
  253. </a>
  254. <a href="">
  255. <img src="static/font-icon/geren.png" alt="">
  256. <span>我的</span>
  257. </a>
  258. </footer>
  259. </body>
  260. </html>

CSS代码:

  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. /*设置水平排列的推荐课程*/
  130. /*设置垂直排列的推荐课程*/
  131. main > .update > section {
  132. /* border: 5px solid red; */
  133. display: flex;
  134. flex-flow: column nowrap;
  135. }
  136. main > .update > section > div {
  137. background-color: #fff;
  138. margin: 5px;
  139. /*也转为弹性容器*/
  140. display: flex;
  141. flex-flow: row nowrap;
  142. }
  143. main > .update > section > div img {
  144. width: 350px;
  145. height: 90px;
  146. }
  147. main > .update > section > div > span {
  148. display: flex;
  149. /*文本垂直排列*/
  150. flex-flow: column nowrap;
  151. margin-top: 5px;
  152. padding-left: 10px;
  153. }
  154. main > .update> section > div > span i {
  155. font-style: normal;
  156. background-color: #333333;
  157. color: white;
  158. border-radius: 4px;
  159. padding: 0 5px;
  160. font-size: smaller;
  161. }
  162. /* 最新文章 */
  163. /*设置垂直排列的推荐课程*/
  164. main > .wenzhang> section {
  165. /* border: 5px solid red; */
  166. display: flex;
  167. flex-flow: column nowrap;
  168. }
  169. main > .wenzhang > section > div {
  170. background-color: #fff;
  171. margin: 5px;
  172. /*也转为弹性容器*/
  173. display: flex;
  174. flex-flow: row nowrap;
  175. justify-content: space-between;
  176. }
  177. main > .wenzhang > section > div img {
  178. width: 300px;
  179. height: 80px;
  180. }
  181. main > .wenzhang > section > div > span {
  182. display: flex;
  183. /*文本垂直排列*/
  184. flex-flow: column nowrap;
  185. margin-top: 5px;
  186. padding-left: 10px;
  187. }
  188. main > .wenzhang> section > div > span i {
  189. font-style: normal;
  190. background-color: #333333;
  191. color: white;
  192. border-radius: 4px;
  193. padding: 0 5px;
  194. font-size: smaller;
  195. }
  196. /* blog */
  197. /*设置垂直排列的推荐课程*/
  198. main > .blog> section {
  199. /* border: 5px solid red; */
  200. display: flex;
  201. flex-flow: column nowrap;
  202. }
  203. main > .blog > section > div {
  204. height: 60px;
  205. background-color: #fff;
  206. margin: 5px;
  207. padding-left: 10px;
  208. /*也转为弹性容器*/
  209. display: flex;
  210. flex-flow: row nowrap;
  211. justify-content: space-between;
  212. align-items: center;
  213. }
  214. main > .blog > section > div > span {
  215. display: flex;
  216. /*文本垂直排列*/
  217. flex-flow: row nowrap;
  218. justify-content: space-between;
  219. margin-top: 5px;
  220. padding-left: 10px;
  221. }
  222. /* 最新问答 */
  223. /*设置垂直排列的推荐课程*/
  224. main > .ask > section {
  225. /* border: 5px solid red; */
  226. display: flex;
  227. flex-flow: column nowrap;
  228. }
  229. main > .ask > section > div {
  230. height: 60px;
  231. background-color: #fff;
  232. margin: 5px;
  233. padding: 10px;
  234. /*也转为弹性容器*/
  235. display: flex;
  236. flex-flow: row nowrap;
  237. justify-content: space-between;
  238. align-items: center;
  239. }
  240. main > .ask > section > div > span {
  241. display: flex;
  242. /*文本垂直排列*/
  243. flex-flow: row nowrap;
  244. justify-content: space-between;
  245. margin-top: 5px;
  246. padding-left: 10px;
  247. }
  248. /*底部*/
  249. /*暂时将高度设置为2000px,让滚动条出来*/
  250. body {
  251. heigh: 2000px;
  252. }

运行结果如下图:

手抄代码如下:

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议