博客列表 >flex实战应用之php中文网(移动端)

flex实战应用之php中文网(移动端)

麦穗
麦穗原创
2020年04月12日 18:00:36666浏览

flex布局

  • 源码
    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. <link rel="stylesheet" href="static/css/icon.css" />
    7. <link rel="stylesheet" href="static/css/style.css" />
    8. <title>php中文网(手机端)</title>
    9. </head>
    10. <body>
    11. <!-- 页头 -->
    12. <header>
    13. <a href=""><img src="static/images/user.png" alt="" /></a>
    14. <a href=""><img src="static/images/logo.png" alt="" /></a>
    15. <span class="iconfont iconstyle">&#xe61b;</span>
    16. </header>
    17. <!-- 轮播图 -->
    18. <div class="banner">
    19. <img src="static/images/banner.jpg" alt="" />
    20. </div>
    21. <!-- 导航 -->
    22. <nav>
    23. <div>
    24. <a href=""><img src="static/images/navpic1.png" alt="" /></a>
    25. <p>HTML/CSS</p>
    26. </div>
    27. <div>
    28. <a href=""><img src="static/images/navpic2.png" alt="" /></a>
    29. <p>JavaScript</p>
    30. </div>
    31. <div>
    32. <a href=""><img src="static/images/navpic3.png" alt="" /></a>
    33. <p>服务端</p>
    34. </div>
    35. <div>
    36. <a href=""><img src="static/images/navpic4.png" alt="" /></a>
    37. <p>数据库</p>
    38. </div>
    39. <div>
    40. <a href=""><img src="static/images/navpic5.png" alt="" /></a>
    41. <p>移动端</p>
    42. </div>
    43. <div>
    44. <a href=""><img src="static/images/navpic6.png" alt="" /></a>
    45. <p>手册</p>
    46. </div>
    47. <div>
    48. <a href=""><img src="static/images/navpic7.png" alt="" /></a>
    49. <p>工具</p>
    50. </div>
    51. <div>
    52. <a href=""><img src="static/images/navpic8.png" alt="" /></a>
    53. <p>直播</p>
    54. </div>
    55. </nav>
    56. <!-- 推荐课程 -->
    57. <div class="bgcolor">
    58. <p class="ptitle">推荐课程</p>
    59. <div class="course">
    60. <div class="course-unit">
    61. <img src="static/images/movpic1.jpg" alt="" />
    62. <img src="static/images/movpic2.jpg" alt="" />
    63. </div>
    64. <div class="course-unit">
    65. <img src="static/images/movpic3.jpg" alt="" />
    66. <div class="course-text">
    67. <p>CI框架30分钟极速入门</p>
    68. <div>
    69. <span class="level">中级</span>
    70. <span>61263次播放</span>
    71. </div>
    72. </div>
    73. </div>
    74. <div class="course-unit">
    75. <img src="static/images/movpic4.jpg" alt="" />
    76. <div class="course-text">
    77. <p>2018前端入门_HTML5</p>
    78. <div>
    79. <span class="level">初级</span>
    80. <span>310328次播放</span>
    81. </div>
    82. </div>
    83. </div>
    84. </div>
    85. </div>
    86. <!-- 最新更新 -->
    87. <div class="bgcolor">
    88. <p class="ptitle">最新更新</p>
    89. <div class="course1">
    90. <div class="course-unit1">
    91. <img src="static/images/movpic5.jpg" alt="" />
    92. <div class="course-text1">
    93. <p>PHP快速操控Excel之PhpSpreadsheet</p>
    94. <span class="synopsis">
    95. 老的PHPExcel已经停止更新了!目前最新的是使用phpOffice插件PhpSpreadsh
    96. </span>
    97. <div>
    98. <span class="level">高级</span>
    99. <span>310328次播放</span>
    100. </div>
    101. </div>
    102. </div>
    103. <div class="course-unit1">
    104. <img src="static/images/movpic6.jpg" alt="" />
    105. <div class="course-text1">
    106. <p>Thinkphp6.0正式版视频教程</p>
    107. <span class="synopsis"
    108. >Thinkphp6.0从2019年10月24日正式发布,相对测试版,有很多变动,目前TP6已</span
    109. >
    110. <div>
    111. <span class="level">初级</span>
    112. <span>310328次播放</span>
    113. </div>
    114. </div>
    115. </div>
    116. <div class="course-unit1">
    117. <img src="static/images/movpic7.jpg" alt="" />
    118. <div class="course-text1">
    119. <p>2019python自学视频</p>
    120. <span class="synopsis"
    121. >本课程适合想从零开始学习
    122. Python编程语言的开发人员。由浅入深的带你进入</span
    123. >
    124. <div>
    125. <span class="level">中级</span>
    126. <span>310328次播放</span>
    127. </div>
    128. </div>
    129. </div>
    130. <div class="course-unit1">
    131. <img src="static/images/movpic8.jpg" alt="" />
    132. <div class="course-text1">
    133. <p>PHP开发免费公益直播课</p>
    134. <span class="synopsis"
    135. >主讲:php中文网-朱老师( Peter Zhu) 时间:2019.10.17 晚
    136. 20:00-22:00 主题</span
    137. >
    138. <div>
    139. <span class="level">初级</span>
    140. <span>310328次播放</span>
    141. </div>
    142. </div>
    143. </div>
    144. <div class="course-unit1">
    145. <img src="static/images/movpic9.jpg" alt="" />
    146. <div class="course-text1">
    147. <p>从零开始到WEB响应式布局</p>
    148. <span class="synopsis"
    149. >重点介绍了HTML、CSS、web布局前端核心技术,通过视频讲解,了解可以利</span
    150. >
    151. <div>
    152. <span class="level">中级</span>
    153. <span>310328次播放</span>
    154. </div>
    155. </div>
    156. </div>
    157. <div class="course-unit1">
    158. <img src="static/images/movpic10.jpg" alt="" />
    159. <div class="course-text1">
    160. <p>PHP文件基础操作</p>
    161. <span class="synopsis"
    162. >好多同学在PHP基础的时候对PHP文件的操作了解的不够多,本节课就带着大家</span
    163. >
    164. <div>
    165. <span class="level">初级</span>
    166. <span>310328次播放</span>
    167. </div>
    168. </div>
    169. </div>
    170. </div>
    171. </div>
    172. <!-- 最新文章 -->
    173. <div class="bgcolor">
    174. <p class="ptitle">最新文章</p>
    175. <div class="news">
    176. <div class="new-unit1">
    177. <div class="new">
    178. <p>sublime正则搜索替换修改数据的方法</p>
    179. <p>发布时间:2020年4月11日</p>
    180. </div>
    181. <img src="static/images/newpic1.jpg" alt="" />
    182. </div>
    183. </div>
    184. <div class="news">
    185. <div class="new-unit1">
    186. <div class="new">
    187. <p>为什么我的电脑只有C盘电脑只有C盘电脑只有C盘</p>
    188. <p>发布时间:2020年4月11日</p>
    189. </div>
    190. <img src="static/images/newpic2.jpg" alt="" />
    191. </div>
    192. </div>
    193. <div class="news">
    194. <div class="new-unit1">
    195. <div class="new">
    196. <p>dedecms如何添加并引入php文件</p>
    197. <p>发布时间:2020年4月11日</p>
    198. </div>
    199. <img src="static/images/newpic3.jpg" alt="" />
    200. </div>
    201. </div>
    202. <div class="news">
    203. <div class="new-unit1">
    204. <div class="new">
    205. <p>扩展分区转主分区的方法</p>
    206. <p>发布时间:2020年4月11日</p>
    207. </div>
    208. <img src="static/images/newpic4.jpg" alt="" />
    209. </div>
    210. </div>
    211. <div class="news">
    212. <div class="new-unit1">
    213. <div class="new">
    214. <p>2020全新Java面试题——容器(二)</p>
    215. <p>发布时间:2020年4月11日</p>
    216. </div>
    217. <img src="static/images/newpic5.jpg" alt="" />
    218. </div>
    219. </div>
    220. <div class="news">
    221. <div class="new-unit2">
    222. <a href="">更多内容</a>
    223. </div>
    224. </div>
    225. </div>
    226. <!-- 最新博文 -->
    227. <div class="bgcolor">
    228. <p class="ptitle">最新博文</p>
    229. <div class="course1">
    230. <div class="artical">
    231. <a href="">Jquery+AJAX上传文件,无刷新上传并重命名文件</a>
    232. <a href="">2020-4-11</a>
    233. </div>
    234. <div class="artical">
    235. <a href="">thinkphp5.6源码阅读</a>
    236. <a href="">2020-4-11</a>
    237. </div>
    238. <div class="artical">
    239. <a href="">Composer windows安装详细介绍</a>
    240. <a href="">2020-4-11</a>
    241. </div>
    242. <div class="artical">
    243. <a href="">AI智能电销机器人源码 源码解读(1)—基础</a>
    244. <a href="">2020-4-11</a>
    245. </div>
    246. <div class="artical">
    247. <a href="http://www.baidu.com/">利用css过滤实现玩网页夜模式适配</a>
    248. <a href="">2020-4-11</a>
    249. </div>
    250. <div class="news">
    251. <div class="new-unit2">
    252. <a href="">更多内容</a>
    253. </div>
    254. </div>
    255. </div>
    256. </div>
    257. <!-- 最新问答 -->
    258. <div class="bgcolor">
    259. <p class="ptitle">最新问答</p>
    260. <div class="course1">
    261. <div class="artical">
    262. <a href="">制定的学习计划在哪能找到 咋找不到呢?</a>
    263. <a href="">2020-4-11</a>
    264. </div>
    265. <div class="artical">
    266. <a href="">数据库链接后怎么知道用哪个表啊</a>
    267. <a href="">2020-4-11</a>
    268. </div>
    269. <div class="artical">
    270. <a href="">这个同步的东西</a>
    271. <a href="">2020-4-11</a>
    272. </div>
    273. <div class="artical">
    274. <a href="">想要实现搜索后定位到搜索城市的位置</a>
    275. <a href="">2020-4-11</a>
    276. </div>
    277. <div class="artical">
    278. <a href="http://www.baidu.com/">我访问不了</a>
    279. <a href="">2020-4-11</a>
    280. </div>
    281. <div class="news">
    282. <div class="new-unit2">
    283. <a href="">更多内容</a>
    284. </div>
    285. </div>
    286. </div>
    287. </div>
    288. <div style="height: 40px;"></div>
    289. <!-- 页脚 -->
    290. <footer>
    291. <a href="">
    292. <span class="iconfont">&#xe63a;</span>
    293. <span>首页</span>
    294. </a>
    295. <a href="">
    296. <span class="iconfont">&#xe78f;</span>
    297. <span>视频</span>
    298. </a>
    299. <a href="">
    300. <span class="iconfont">&#xe627;</span>
    301. <span>社区</span>
    302. </a>
    303. <a href="">
    304. <span class="iconfont">&#xe621;</span>
    305. <span>我的</span>
    306. </a>
    307. </footer>
    308. </body>
    309. </html>
  • css样式
    ```html
  • {
    margin: 0;
    padding: 0;
    }
    a {
    text-decoration: none;
    color: #666;
    }
    html {
    width: 100vw;
    height: 100vh;
    font-size: 14px;
    }
    body {
    min-width: 360px;
    background-color: white;
    display: flex;
    flex-flow: column nowrap;
    }
    / 图标样式 /
    .iconstyle {
    font-size: 1.6rem;
    color: aliceblue;
    }
    / 页头、页脚共用样式 /
    header,
    footer {
    height: 6vh;
    }
    / 页头样式 /
    header {
    background-color: #333;
    padding: 0 11px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    width: 100vw;
    }
    header a:first-of-type {
    width: 30px;
    }
    header a:last-of-type {
    width: 100px;
    }
    header img {
    width: 100%;
    }
    / 轮播图样式 /
    .banner {
    margin-top: 40px;
    height: 160px;
    }
    .banner img {
    width: 100%;
    }
    / 导航样式 /
    nav {
    height: 180px;
    box-sizing: border-box;
    display: flex;
    flex-flow: row wrap;
    align-content: center;
    }
    nav > div {
    width: 25vw;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    flex-flow: column nowrap;
    align-items: center;
    }
    nav > div img {
    width: 60%;
    }
    nav > div a {
    text-align: center;
    }
    nav > div p {
    font-size: 1.2rem;
    font-weight: bold;
    font-family: “Segoe UI”, Tahoma, Geneva, Verdana, sans-serif;
    color: #666;
    }
    / bgcolor,title标题样式 /
    .bgcolor {
    background-color: lavender;
    }
    .ptitle {
    font-size: 1.5rem;
    padding-left: 15px;
    padding-top: 25px;
    padding-bottom: 20px;
    box-sizing: border-box;
    color: #555;
    font-weight: 600;
    font-family: Cambria, Cochin, Georgia, Times, “Times New Roman”, serif;
    }
    / 推荐课程 /
    .course {
    display: flex;
    flex-flow: column nowrap;
    align-items: center;
    }
    .course > .course-unit {
    box-sizing: border-box;
    width: 100vw;
    display: flex;
    }
    .course-unit img {
    padding: 10px;
    box-sizing: border-box;
    width: 100%;
    }
    .course-unit:not(:first-of-type) {
    width: 95vw;
    margin-bottom: 10px;
    background-color: white;
    box-sizing: border-box;
    }
    .course-unit:not(:first-of-type) img {
    width: 40%;
    }
    .course > .course-unit p {
    font-size: 1.2rem;
    color: #555;
    font-family: “Franklin Gothic Medium”, “Arial Narrow”, Arial, sans-serif;
    }
    .course-unit > .course-text {
    display: flex;
    flex-flow: column nowrap;
    }
    .course-text > p {
    padding: 10px 0px;
    box-sizing: border-box;
    align-self: flex-start;
    }
    .level {
    width: 25px;
    height: 14px;
    font-size: 1.1rem;
    padding: 0 3px;
    color: #dfdfdf;
    background-color: #666;
    border-radius: 8px;
    }
    .course-text > div > span:last-of-type {
    color: #666;
    font-size: 0.9rem;
    }
    / 最新更新 /
    .course1 {
    display: flex;
    flex-flow: column nowrap;
    align-items: center;
    }
    .course1 > .course-unit1 {
    box-sizing: border-box;
    width: 95vw;
    display: flex;
    }
    .course-unit1 img {
    padding: 10px;
    box-sizing: border-box;
    width: 100%;
    }
    .course-unit1 {
    height: 100px;
    margin-bottom: 10px;
    background-color: white;
    box-sizing: border-box;
    }
    .course-unit1 img {
    width: 40%;
    }
    .course1 > .course-unit1 p {
    font-size: 1.2rem;
    color: #555;
    font-family: “Franklin Gothic Medium”, “Arial Narrow”, Arial, sans-serif;
    }
    .course-unit1 > .course-text1 {
    width: 55vw;
    display: flex;
    flex-flow: column nowrap;
    justify-content: space-evenly;
    }
    .synopsis {
    width: auto;
    font-size: 0.8rem;
    color: #888;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    }
    .course-text1 > p {
    width: 90%;
    padding: 5px 0px;
    box-sizing: border-box;
    align-self: flex-start;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    }
    .course-text1 > div > span:last-of-type {
    color: #666;
    font-size: 0.9rem;
    }
    / 最新文章样式 /
    .news {
    display: flex;
    flex-flow: column nowrap;
    align-items: center;
    }
    .new-unit1 {
    width: 95vw;
    padding: 0 10px;
    margin-bottom: 10px;
    box-sizing: border-box;
    background-color: white;
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    }
    .new-unit1 img {
    width: 30%;
    padding: 10px;
    margin-left: auto;
    }
    .new-unit1 > .new {
    width: 55vw;
    display: flex;
    flex-flow: column nowrap;
    justify-content: space-between;
    }
    .new p {
    color: #666;
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    display: flex;
    flex-flow: column nowrap;
    }
    .new p:last-of-type {
    font-size: smaller;
    }
    .new-unit2 > a {
    width: 95vw;
    height: 35px;
    padding: 0 10px;
    margin-bottom: 10px;
    box-sizing: border-box;
    background-color: white;
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    justify-content: center;
    }
    / 最新博文 /
    .course1 > .artical {
    width: 95vw;
    height: 50px;
    padding: 0 10px;
    margin-bottom: 10px;
    box-sizing: border-box;
    background-color: white;
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    justify-content: space-between;
    }
    .artical a:first-of-type {
    width: 70vw;
    }
    .artical a {
    font-size: 1.1rem;
    color: #666;
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    }
    / 页脚样式 /
    footer {
    background-color: darkgray;
    display: flex;
    align-items: center;
    position: fixed;
    width: 100vw;
    bottom: 0;
    }
    footer > a {
    width: 25vw;
    display: flex;
    align-items: center;
    flex-flow: column nowrap;
    }
    footer > a span:first-of-type {
    font-size: 1.3rem;
    color: azure;
    }
    footer > a span:last-of-type {
    color: whitesmoke;
    }
    ```

显示效果

学习总结:

1.理论和实战还是存在非常大的差距的,心里想着会了,并不是真的会了,实战的时候还是会遇到各种各样的问题,虽然这只是前端的基础知识。
2.flex布局我也是才接触,运用不熟练,眼高手低,也是纠结了很长时间
3.希望多增加实战课程和作业

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