博客列表 >使用flex布局实现PHP中文网移动端网页布局

使用flex布局实现PHP中文网移动端网页布局

王珂
王珂原创
2020年04月13日 19:57:50605浏览

使用flex布局实现PHP中文网移动端网页布局

  1. <html>
  2. <head>
  3. <meta charset="UTF-8" />
  4. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  5. <link rel="stylesheet" href="static/css/font-icon.css" />
  6. <title>PHP中文网</title>
  7. <style>
  8. /* 初始化 */
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. }
  13. a {
  14. text-decoration: none;
  15. color: #666;
  16. }
  17. html {
  18. /* vw: 可视区宽度,100vw:表示占满100份 */
  19. width: 100vw;
  20. height: 100vh;
  21. /* 在html中设置字体大小, 给后的rem单位用 */
  22. font-size: 14px;
  23. }
  24. body {
  25. min-width: 360px;
  26. background-color: #fff;
  27. display: flex;
  28. flex-flow: column nowrap;
  29. }
  30. body > header {
  31. background-color: #333;
  32. color: white;
  33. height: 30px;
  34. display: flex;
  35. align-items: center;
  36. justify-content: space-between;
  37. padding: 0 15px;
  38. position: fixed;
  39. width: 95vw;
  40. }
  41. body > header > a:first-of-type {
  42. width: 15%;
  43. }
  44. body > header > a > img:last-of-type {
  45. width: 50%;
  46. }
  47. body > .slider {
  48. padding: 15px 0;
  49. height: 150px;
  50. }
  51. body > .slider > img {
  52. width: 100%;
  53. }
  54. /* 主导航区 */
  55. nav {
  56. height: 200px;
  57. display: flex;
  58. /* 变成多行容器 */
  59. flex-flow: row wrap;
  60. }
  61. nav > div {
  62. /* 占宽度四分之一 */
  63. width: 25vw;
  64. display: flex;
  65. flex-flow: column nowrap;
  66. align-items: center;
  67. }
  68. nav > div > a:first-of-type {
  69. text-align: center;
  70. }
  71. nav > div img {
  72. width: 50%;
  73. }
  74. .hot {
  75. color: coral;
  76. }
  77. .title {
  78. font-size: 1.2rem;
  79. font-weight: normal;
  80. text-align: center;
  81. margin-top: 10px;
  82. }
  83. /* 推荐课程 */
  84. .hot-goods {
  85. border: 1px solid #cfcfcf;
  86. margin-top: 10px;
  87. font-size: 0.8rem;
  88. display: flex;
  89. flex-flow: row wrap;
  90. }
  91. .hot-goods img {
  92. width: 90%;
  93. }
  94. .hot-goods > .goods-img {
  95. padding: 10px;
  96. box-sizing: border-box;
  97. flex: 1 0 100vw;
  98. display: flex;
  99. flex-flow: row nowrap;
  100. justify-content: center;
  101. }
  102. .hot-goods > .goods-img > div {
  103. display: flex;
  104. justify-content: space-around;
  105. }
  106. /* 最新课程 */
  107. .list-goods {
  108. padding: 10px;
  109. box-sizing: border-box;
  110. border: 1px solid #cfcfcf;
  111. font-size: 0.8rem;
  112. margin-top: 10px;
  113. display: flex;
  114. flex-flow: column nowrap;
  115. height: 100px;
  116. }
  117. .list-goods > .goods-desc {
  118. display: flex;
  119. margin: 5px 0;
  120. }
  121. .list-goods img {
  122. width: 45vw;
  123. height: 70%;
  124. }
  125. .list-goods > .goods-desc > a {
  126. padding: 5px;
  127. box-sizing: border-box;
  128. }
  129. .list-goods > .goods-desc > a:hover {
  130. color: lightseagreen;
  131. }
  132. /* 页脚 */
  133. body > footer {
  134. color: #666;
  135. background-color: #efefef;
  136. border-top: 1px solid #ccc;
  137. height: 55px;
  138. position: fixed;
  139. bottom: 0;
  140. width: 100vw;
  141. display: flex;
  142. justify-content: space-around;
  143. }
  144. body > footer > a {
  145. margin-top: 10px;
  146. font-size: 0.8rem;
  147. display: flex;
  148. flex-flow: column nowrap;
  149. align-items: center;
  150. }
  151. body > footer > a > span:first-of-type {
  152. font-size: 1.6rem;
  153. }
  154. </style>
  155. </head>
  156. <body>
  157. <!-- 页眉 -->
  158. <header>
  159. <a href=""><img src="static/images/phpcn/login.png" alt="" /></a>
  160. <a href=""><img src="static/images/phpcn/logo.png" alt="" /></a>
  161. <span class="iconfont"></span>
  162. </header>
  163. <!-- 轮播图 -->
  164. <div class="slider">
  165. <img src="static/images/phpcn/banner.png" alt="" />
  166. </div>
  167. <!--主导航区-->
  168. <nav>
  169. <div>
  170. <a href=""><img src="static/images/phpcn/nav1.png" alt="" /></a>
  171. <a href="">HTML/CSS</a>
  172. </div>
  173. <div>
  174. <a href=""><img src="static/images/phpcn/nav2.png" alt="" /></a>
  175. <a href="">JavaScript</a>
  176. </div>
  177. <div>
  178. <a href=""><img src="static/images/phpcn/nav3.png" alt="" /></a>
  179. <a href="">服务端</a>
  180. </div>
  181. <div>
  182. <a href=""><img src="static/images/phpcn/nav4.png" alt="" /></a>
  183. <a href="">数据库</a>
  184. </div>
  185. <div>
  186. <a href=""><img src="static/images/phpcn/nav5.png" alt="" /></a>
  187. <a href="">移动端</a>
  188. </div>
  189. <div>
  190. <a href=""><img src="static/images/phpcn/nav6.png" alt="" /></a>
  191. <a href="">手册</a>
  192. </div>
  193. <div>
  194. <a href=""><img src="static/images/phpcn/nav7.png" alt="" /></a>
  195. <a href="">工具</a>
  196. </div>
  197. <div>
  198. <a href=""><img src="static/images/phpcn/nav8.png" alt="" /></a>
  199. <a href="">直播</a>
  200. </div>
  201. </nav>
  202. <!--推荐课程-->
  203. <h2 class="title">推荐课程</h2>
  204. <div class="hot-goods">
  205. <div class="goods-img">
  206. <a href=""><img src="static/images/phpcn/hot1.jpg" alt="" /></a>
  207. <a href=""><img src="static/images/phpcn/hot2.jpg" alt="" /></a>
  208. </div>
  209. </div>
  210. <!-- 最新更新 -->
  211. <h2 class="title">最新更新</h2>
  212. <div class="list-goods">
  213. <div class="goods-desc">
  214. <a href=""><img src="static/images/phpcn/new1.png" alt="" /></a>
  215. <a href=""
  216. >PHP快速操控Excel之PhpSpreadsheet老的PHPExcel已经停止更新了!目前最新的是使用phpOffice插件PhpSpreadsh<span
  217. class="iconfont hot"
  218. style="vertical-align: middle;"
  219. ></span
  220. ></a
  221. >
  222. </div>
  223. </div>
  224. <div class="list-goods">
  225. <div class="goods-desc">
  226. <a href=""><img src="static/images/phpcn/new3.jpg" alt="" /></a>
  227. <a href=""
  228. >2019python自学视频 本课程适合想从零开始学习 Python
  229. 编程语言的开发人员。由浅入深的带你进入py<span
  230. class="iconfont hot"
  231. style="vertical-align: middle;"
  232. ></span
  233. ></a
  234. >
  235. </div>
  236. </div>
  237. <div class="list-goods">
  238. <div class="goods-desc">
  239. <a href=""><img src="static/images/phpcn/new2.png" alt="" /></a>
  240. <a href=""
  241. >Thinkphp6.0正式版视频教程
  242. Thinkphp6.0从2019年10月24日正式发布,相对测试版,有很多变动,目前TP<span
  243. class="iconfont hot"
  244. style="vertical-align: middle;"
  245. ></span
  246. ></a
  247. >
  248. </div>
  249. </div>
  250. <!--页脚-->
  251. <footer>
  252. <a href="">
  253. <span class="iconfont hot"></span>
  254. <span>首页</span>
  255. </a>
  256. <a href="">
  257. <span class="iconfont hot"></span>
  258. <span>视频</span>
  259. </a>
  260. <a href="">
  261. <span class="iconfont hot"></span>
  262. <span>社区</span>
  263. </a>
  264. <a href="">
  265. <span class="iconfont hot"></span>
  266. <span>我的</span>
  267. </a>
  268. </footer>
  269. </body>
  270. </html>

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