博客列表 >php中文网移动端首页(样式和HTML高亮版 Flex版12月27)

php中文网移动端首页(样式和HTML高亮版 Flex版12月27)

孤心泪的博客
孤心泪的博客原创
2019年12月30日 17:02:20825浏览

html代码和css代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width,initial-scale=1.0">
  7. <title>移动端flex首页</title>
  8. <link rel="stylesheet" href="../../font/iconfont.css">
  9. <link rel="stylesheet" href="1227.css">
  10. </head>
  11. <body>
  12. <!--布局原则:宽度自适应,高度固定-->
  13. <!--顶部-->
  14. <header>
  15. <img src="https://img.php.cn/upload/avatar/000/000/001/f917a88f277796c0db13782f48336be9.jpg" alt="" class="user">
  16. <img src="../../image/logo.png" alt="" class="logo">
  17. <a href="">
  18. <i class="iconfont icon-liebiao"></i>
  19. </a>
  20. </header>
  21. <main>
  22. <!--轮播-->
  23. <section class="banner">
  24. <img src="https://m.php.cn/static/images/ico/6.png" alt="">
  25. </section>
  26. <!--导航-->
  27. <nav>
  28. <a href="">
  29. <img src="https://m.php.cn/static/images/ico/html.png" alt="">
  30. <span>html/css</span>
  31. </a>
  32. <a href="">
  33. <img src="https://m.php.cn/static/images/ico/html.png" alt="">
  34. <span>html/css</span>
  35. </a>
  36. <a href="">
  37. <img src="https://m.php.cn/static/images/ico/html.png" alt="">
  38. <span>html/css</span>
  39. </a>
  40. <a href="">
  41. <img src="https://m.php.cn/static/images/ico/html.png" alt="">
  42. <span>html/css</span>
  43. </a>
  44. <a href="">
  45. <img src="https://m.php.cn/static/images/ico/html.png" alt="">
  46. <span>html/css</span>
  47. </a>
  48. <a href="">
  49. <img src="https://m.php.cn/static/images/ico/html.png" alt="">
  50. <span>html/css</span>
  51. </a>
  52. <a href="">
  53. <img src="https://m.php.cn/static/images/ico/html.png" alt="">
  54. <span>html/css</span>
  55. </a>
  56. <a href="">
  57. <img src="https://m.php.cn/static/images/ico/html.png" alt="">
  58. <span>html/css</span>
  59. </a>
  60. </nav>
  61. <section class="course">
  62. <h3>推荐课程</h3>
  63. <div class="course-top">
  64. <a class="course-item">
  65. <img src="https://img.php.cn/upload/course/000/000/001/5d242759adb88970.jpg" alt="">
  66. </a>
  67. <a class="course-item">
  68. <img src="https://img.php.cn/upload/course/000/000/001/5d242759adb88970.jpg" alt="">
  69. </a>
  70. </div>
  71. <div class="course-bottom">
  72. <a>
  73. <img src="https://img.php.cn/upload/course/000/000/035/5d2941e265889366.jpg" alt="">
  74. <div class="course-bottom-right">
  75. <h2>标题</h2>
  76. <div>
  77. <span class="level">中级</span>
  78. <span>454678次播放</span>
  79. </div>
  80. </div>
  81. </a>
  82. <a>
  83. <img src="https://img.php.cn/upload/course/000/000/035/5d2941e265889366.jpg" alt="">
  84. <div class="course-bottom-right">
  85. <h2>标题</h2>
  86. <div>
  87. <span class="level">中级</span>
  88. <span>454678次播放</span>
  89. </div>
  90. </div>
  91. </a>
  92. </div>
  93. </section>
  94. <section class="recent">
  95. <h3>最新更新</h3>
  96. <div class="recent-list">
  97. <a>
  98. <img src="https://img.php.cn/upload/course/000/000/014/5db2b53c67bca626.jpg" alt="">
  99. <div>
  100. <h2>标题</h2>
  101. <p>简述</p>
  102. <div>
  103. <span class="level">中级</span>
  104. <span>454678次播放</span>
  105. </div>
  106. </div>
  107. </a>
  108. <a>
  109. <img src="https://img.php.cn/upload/course/000/000/014/5db2b53c67bca626.jpg" alt="">
  110. <div>
  111. <h2>标题</h2>
  112. <p>简述</p>
  113. <div>
  114. <span class="level">中级</span>
  115. <span>454678次播放</span>
  116. </div>
  117. </div>
  118. </a>
  119. <a>
  120. <img src="https://img.php.cn/upload/course/000/000/014/5db2b53c67bca626.jpg" alt="">
  121. <div>
  122. <h2>标题</h2>
  123. <p>简述</p>
  124. <div>
  125. <span class="level">中级</span>
  126. <span>454678次播放</span>
  127. </div>
  128. </div>
  129. </a>
  130. </div>
  131. </section>
  132. <section class="articles">
  133. <h3>最新文章</h3>
  134. <div class="articles-list">
  135. <a>
  136. <div>
  137. <h2>标题</h2>
  138. <span>发布时间:2019-12-30</span>
  139. </div>
  140. <img src="https://img.php.cn/upload/article/000/000/041/5e0720ee3461b750.jpg" alt="">
  141. </a>
  142. <a>
  143. <div>
  144. <h2>标题</h2>
  145. <span>发布时间:2019-12-30</span>
  146. </div>
  147. <img src="https://img.php.cn/upload/article/000/000/041/5e0720ee3461b750.jpg" alt="">
  148. </a>
  149. <a>
  150. <div>
  151. <h2>标题</h2>
  152. <span>发布时间:2019-12-30</span>
  153. </div>
  154. <img src="https://img.php.cn/upload/article/000/000/041/5e0720ee3461b750.jpg" alt="">
  155. </a>
  156. <a>
  157. <div>
  158. <h2>标题</h2>
  159. <span>发布时间:2019-12-30</span>
  160. </div>
  161. <img src="https://img.php.cn/upload/article/000/000/041/5e0720ee3461b750.jpg" alt="">
  162. </a>
  163. <a href="" class="more">更多内容</a>
  164. </div>
  165. </section>
  166. <section class="blogs">
  167. <h3>最新博文</h3>
  168. <div class="blogs-list">
  169. <a href="">
  170. <h2>composer安装laravel,nginx服务器路配置解决404问题,创建简单的控制器 - 20191227</h2>
  171. <span>2019-12-30</span>
  172. </a>
  173. <a href="">
  174. <h2>composer安装laravel,nginx服务器路配置解决404问题,创建简单的控制器 - 20191227</h2>
  175. <span>2019-12-30</span>
  176. </a>
  177. <a href="">
  178. <h2>composer安装laravel,nginx服务器路配置解决404问题,创建简单的控制器 - 20191227</h2>
  179. <span>2019-12-30</span>
  180. </a>
  181. <a href="">
  182. <h2>composer安装laravel,nginx服务器路配置解决404问题,创建简单的控制器 - 20191227</h2>
  183. <span>2019-12-30</span>
  184. </a>
  185. <a href="" class="more">更多内容</a>
  186. </div>
  187. </section>
  188. <section class="blogs">
  189. <h3>最新问答</h3>
  190. <div class="blogs-list">
  191. <a href="">
  192. <h2>composer安装laravel,nginx服务器路配置解决404问题,创建简单的控制器 - 20191227</h2>
  193. <span>2019-12-30</span>
  194. </a>
  195. <a href="">
  196. <h2>composer安装laravel,nginx服务器路配置解决404问题,创建简单的控制器 - 20191227</h2>
  197. <span>2019-12-30</span>
  198. </a>
  199. <a href="">
  200. <h2>composer安装laravel,nginx服务器路配置解决404问题,创建简单的控制器 - 20191227</h2>
  201. <span>2019-12-30</span>
  202. </a>
  203. <a href="">
  204. <h2>composer安装laravel,nginx服务器路配置解决404问题,创建简单的控制器 - 20191227</h2>
  205. <span>2019-12-30</span>
  206. </a>
  207. <a href="" class="more">更多内容</a>
  208. </div>
  209. </section>
  210. </main>
  211. <footer>
  212. <a href="" class="active">
  213. <span><i class="iconfont icon-daohangshouye"></i></span>
  214. <span>首页</span>
  215. </a>
  216. <a href="">
  217. <span><i class="iconfont icon-daohangshouye"></i></span>
  218. <span>视频</span>
  219. </a>
  220. <a href="">
  221. <span><i class="iconfont icon-daohangshouye"></i></span>
  222. <span>社区</span>
  223. </a>
  224. <a href="">
  225. <span><i class="iconfont icon-huiyuan1"></i></span>
  226. <span>我的</span>
  227. </a>
  228. </footer>
  229. </body>
  230. </html>

css代码
/初始化样式/

  1. * {
  2. margin: 0;
  3. padding: 0;
  4. }
  5. a {
  6. text-decoration: none;
  7. color: #333;
  8. }
  9. body {
  10. display: flex;
  11. flex-direction: column;
  12. min-width: 360px;
  13. max-width: 768px;
  14. height: 100vh;
  15. width: 100vw;
  16. box-sizing: border-box;
  17. background-color: #edeff0;
  18. }
  19. h3 {
  20. padding-bottom: 10px;
  21. font-size: 18px;
  22. font-weight: bold;
  23. }
  24. /*头部和顶部*/
  25. body>header ,body > footer {
  26. display: flex;
  27. height: 8vh;
  28. width: 100vw;
  29. background-color: darkgray;
  30. }
  31. body > footer{
  32. border-top: 1px solid #cccccc;
  33. }
  34. body>header {
  35. justify-content: space-between;
  36. align-items: center;
  37. box-shadow: 0 0 10px 1px rgba(7, 17, 27, .1);
  38. background-color: #2d353c;
  39. }
  40. body>header>.user {
  41. width: 23px;
  42. height: 23px;
  43. border-radius: 50%;
  44. border: 1px solid #8f9498;
  45. margin-left: 5px;
  46. }
  47. body>header>a>i.iconfont{
  48. font-size: 24px;
  49. color: #fff;
  50. font-weight: bold;
  51. padding-right: 15px;
  52. }
  53. body>header>.logo{
  54. width: 94px;
  55. height: 42px;
  56. display: block;
  57. }
  58. body > footer >a {
  59. background: #eee;
  60. width: 25%;
  61. display: flex;
  62. flex-direction: column;
  63. align-items: center;
  64. box-sizing: border-box;
  65. padding: 5px 0;
  66. color: #888;
  67. }
  68. body > footer >a.active{
  69. color: red;
  70. }
  71. /*主体*/
  72. body > main {
  73. flex: 1;
  74. overflow-x: hidden;
  75. overflow-y: auto;
  76. display: flex;
  77. flex-direction: column;
  78. /*background-color: #44aaee;*/
  79. }
  80. /*轮播*/
  81. body>main>section.banner {
  82. width: 100vw;
  83. height: 22vh;
  84. }
  85. body>main>section.banner>img {
  86. width: 100%;
  87. height: 100%;
  88. }
  89. /*导航*/
  90. body>main>nav{
  91. background-color: #fff;
  92. width: 100vw;
  93. height: 25vh;
  94. display: flex;
  95. flex-flow: row wrap;
  96. justify-content: space-between;
  97. align-content: space-between;
  98. }
  99. body>main>nav>a{
  100. width: 25vw;
  101. height: 12.5vh;
  102. display: flex;
  103. flex-direction: column;
  104. justify-content: center;
  105. align-items: center;
  106. /*flex-basis: 25%;*/
  107. }
  108. body>main>nav>a>img {
  109. width: 45px;
  110. height: 45px;
  111. margin-bottom: 1vh;
  112. display: block;
  113. }
  114. /*推荐课程*/
  115. body>main>.course {
  116. margin-top: 5vh;
  117. padding: 2.7vw 2.7vw 2.7vw;
  118. }
  119. .course-top {
  120. width: 100%;
  121. display: flex;
  122. justify-content: space-between;
  123. margin-bottom: 2vh;
  124. }
  125. .course-top>a{
  126. width: 49%;
  127. height: 13vh;
  128. }
  129. .course-top>a>img{
  130. width: 100%;
  131. height: 100%;
  132. }
  133. .course-bottom{
  134. display: flex;
  135. flex-direction: column;
  136. }
  137. .course-bottom>a{
  138. display: flex;
  139. background-color: #fff;
  140. width: 100%;
  141. padding: 9px 0 9px 10px ;
  142. margin-bottom: 20px;
  143. }
  144. .course-bottom>a>img{
  145. height: 80px;
  146. margin-right: 2.5vw;
  147. }
  148. .course-bottom-right>h2{
  149. overflow: hidden;
  150. white-space: nowrap;
  151. text-overflow: ellipsis;
  152. margin-bottom: 10px;
  153. font-size: 20px;
  154. color: #888;
  155. }
  156. .course-bottom-right>div{
  157. display: flex;
  158. align-items: center;
  159. width: 100%;
  160. }
  161. .level {
  162. background: #595757;
  163. border-radius: 8px;
  164. color: #fff;
  165. font-size: 10px;
  166. padding: 3px;
  167. line-height: 20px;
  168. margin-right: 5px;
  169. }
  170. /*最新更新*/
  171. body>main>.recent {
  172. padding: 2.7vw 2.7vw 2.7vw;
  173. }
  174. .recent-list>a{
  175. display: flex;
  176. background-color: #fff;
  177. width: 100%;
  178. padding: 9px 0 9px 10px ;
  179. margin-bottom: 20px;
  180. }
  181. .recent-list>a>div>h2{
  182. overflow: hidden;
  183. white-space: nowrap;
  184. text-overflow: ellipsis;
  185. font-size: 20px;
  186. color: #888;
  187. }
  188. .recent-list>a>img{
  189. height: 80px;
  190. margin-right: 2.5vw;
  191. }
  192. .recent-list>a>div>p{
  193. margin-top: 11px;
  194. font-size: 11px;
  195. }
  196. .recent-list>a>div>div{
  197. margin-top: 11px;
  198. }
  199. /*最新文章*/
  200. body>main>.articles {
  201. padding: 2.7vw 2.7vw 2.7vw;
  202. }
  203. .articles-list>a{
  204. display: flex;
  205. background-color: #fff;
  206. border-bottom: 1px solid #eee;
  207. padding: 10px 10px 8px 10px;
  208. box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .1);
  209. justify-content: space-between;
  210. margin-bottom: 10px;
  211. }
  212. .articles-list>a>img{
  213. height: 65px;
  214. width: 30%;
  215. }
  216. .articles-list>a>div>h2{
  217. font-size: 14px;
  218. margin-bottom: 10px;
  219. }
  220. .articles-list>a>div>span{
  221. font-size: 12px;
  222. color: #888;
  223. }
  224. .articles-list>a.more {
  225. justify-content: center;
  226. margin: 0 auto;
  227. line-height: 10px;
  228. background: #fff;
  229. padding: 10px 0;
  230. color: #888;
  231. }
  232. /*最新博文*/
  233. .blogs{
  234. padding: 2.7vw 2.7vw 2.7vw;
  235. }
  236. .blogs-list>a{
  237. display: flex;
  238. align-items: center;
  239. justify-content: space-between;
  240. border-bottom: 1px solid #eee;
  241. padding:10px 10px 8px 10px;
  242. box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .1);
  243. background: #fff;
  244. color: #888888;
  245. margin-bottom: 10px;
  246. }
  247. .blogs-list>a>h2{
  248. font-size: 14px;
  249. font-weight: bold;
  250. white-space: nowrap;
  251. overflow: hidden;
  252. text-overflow: ellipsis;
  253. margin-bottom: 10px;
  254. width: 68%;
  255. }
  256. .blogs-list>a>span{
  257. font-size: 12px;
  258. }
  259. .blogs-list>a.more {
  260. width: 100%;
  261. justify-content: center;
  262. margin: 0 auto;
  263. line-height: 10px;
  264. background: #fff;
  265. padding: 10px 0;
  266. color: #888;
  267. }

效果图

总结
1.css代码有很多重复,没有抽离出来做公共样式
2.布局时简单构思了大致的几个区块,没有细致划分(细致的划分区域可以分离出公共的组件和样式)

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