Blogger Information
Blog 22
fans 0
comment 0
visits 11791
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
flex实战移动端页面布局—Php第十期线上班
Original
459 people have browsed it

2019.12.27作业

移动端m.php.cn布局(flex)实现

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>1227作业</title>
  6. <link rel="stylesheet" href="../static/font/iconfont.css">
  7. <link rel="stylesheet" href="PC-PAGE.css">
  8. </head>
  9. <body>
  10. <header>
  11. <a href=""><i class="iconfont icon-huiyuan2"></i>登录</a>
  12. <img src="../static/images/logo.png" alt="">
  13. <a href=""><i class="iconfont"></i></a>
  14. </header>
  15. <main>
  16. <header><img src="../static/images/ad/ad2.jpg" alt="" height="100%"></header>
  17. <nav>
  18. <a href=""><img src="../static/images/01.png" alt="" height="80" width="80"><span>PS</span></a>
  19. <a href=""><img src="../static/images/02.png" alt="" height="80" width="80"><span>C++</span></a>
  20. <a href=""><img src="../static/images/03.png" alt="" height="80" width="80"><span>ANDROID</span></a>
  21. <a href=""><img src="../static/images/04.png" alt="" height="80" width="80"><span>JAVA</span></a>
  22. <a href=""><img src="../static/images/01.png" alt="" height="80" width="80"><span>PS</span></a>
  23. <a href=""><img src="../static/images/02.png" alt="" height="80" width="80"><span>C++</span></a>
  24. <a href=""><img src="../static/images/03.png" alt="" height="80" width="80"><span>ANDROID</span></a>
  25. <a href=""><img src="../static/images/04.png" alt="" height="80" width="80"><span>JAVA</span></a>
  26. </nav>
  27. <section>
  28. <h2>最近消息</h2>
  29. <article>
  30. <section><img src="../static/images/shop/9.jpg" alt="" width="100%"></section>
  31. <section>2020年1月十大最新热门笔记本电脑</section>
  32. </article>
  33. <article>
  34. <section><img src="../static/images/shop/9.jpg" alt="" width="100%"></section>
  35. <section>2020年1月十大最新热门笔记本电脑</section>
  36. </article>
  37. <article>
  38. <section><img src="../static/images/shop/9.jpg" alt="" width="100%"></section>
  39. <section>2020年1月十大最新热门笔记本电脑</section>
  40. </article>
  41. <article>
  42. <section><img src="../static/images/shop/9.jpg" alt="" width="100%"></section>
  43. <section>2020年1月十大最新热门笔记本电脑</section>
  44. </article>
  45. <article>
  46. <section><img src="../static/images/shop/9.jpg" alt="" width="100%"></section>
  47. <section>2020年1月十大最新热门笔记本电脑</section>
  48. </article>
  49. <article>
  50. <section><img src="../static/images/shop/9.jpg" alt="" width="100%"></section>
  51. <section>2020年1月十大最新热门笔记本电脑</section>
  52. </article>
  53. <article>
  54. <section><img src="../static/images/shop/9.jpg" alt="" width="100%"></section>
  55. <section>2020年1月十大最新热门笔记本电脑</section>
  56. </article>
  57. <article>
  58. <section><img src="../static/images/shop/9.jpg" alt="" width="100%"></section>
  59. <section>2020年1月十大最新热门笔记本电脑</section>
  60. </article>
  61. </section>
  62. </main>
  63. <footer>
  64. <a href=""><i class="iconfont"></i></a>
  65. <a href=""><i class="iconfont"></i></a>
  66. <a href=""><i class="iconfont"></i></a>
  67. </footer>
  68. </body>
  69. </html>

css样式

  1. *{
  2. margin: 0;
  3. /*padding: 0;outline: 1px dashed;*/
  4. }
  5. body{
  6. display: flex;
  7. flex-direction: column;
  8. min-width: 360px;
  9. height: 100vh;
  10. width: 100vw;
  11. }
  12. body > header {
  13. display: flex;
  14. flex-direction: row;
  15. height: 8vh;
  16. width: 100vw;
  17. min-width: 360px;
  18. background-color: black;
  19. box-sizing: border-box;
  20. }
  21. body > header > a {
  22. text-decoration: none;
  23. font-size: 16px;
  24. color: white;
  25. flex: 1;
  26. margin: auto;
  27. }
  28. body > header > a > i {
  29. margin-left: 3px;
  30. margin-right: 3px;
  31. }
  32. body > header > a:last-of-type {
  33. display: flex;
  34. justify-content: flex-end;
  35. margin-right: 3px;
  36. }
  37. body > main {
  38. flex-grow: 1;
  39. overflow: auto;
  40. display: flex;
  41. flex-direction: column;
  42. }
  43. body > main > header{
  44. display: flex;
  45. flex-direction: column;
  46. }
  47. body > main > header > img {
  48. align-self: center;
  49. padding: 1px;
  50. }
  51. body > main > nav {
  52. align-self: center;
  53. display: flex;
  54. flex-wrap: wrap;
  55. flex-direction: row;
  56. width: 400px;
  57. }
  58. body > main > nav > a {
  59. display: flex;
  60. flex-direction: column;
  61. text-decoration: none;
  62. flex-basis: 80px;
  63. flex-grow: 1;
  64. }
  65. body > main > nav > a > img{
  66. align-self: center;
  67. }
  68. body > main > nav > a > span{
  69. font-size: 20px;
  70. color: black;
  71. align-self: center;
  72. }
  73. body > main > section {
  74. /*display: flex;*/
  75. border-top: 1px lightgray solid;
  76. margin: 5px;
  77. }
  78. body > main > section > article{
  79. background-color: lightcyan;
  80. box-shadow: 0 0 2px #888888;
  81. margin: 1vh 0;
  82. display: flex;
  83. }
  84. body > main > section > article > section:first-of-type {
  85. width: 24vw;
  86. height: 10vh;
  87. display: flex;
  88. }
  89. body > main > section > article > section:first-of-type>img{
  90. align-self: center;
  91. margin-left: 1vw;
  92. height: 8vh;
  93. }
  94. body > main > section > article > section:last-of-type {
  95. flex: 1;
  96. background-color: lightcyan;
  97. margin: 0 1vw;
  98. box-shadow: 0 0 2px lightgray;
  99. align-self: center;
  100. padding-left: 30px;
  101. }
  102. body > footer {
  103. display: flex;
  104. flex-direction: row;
  105. height: 8vh;
  106. width: 100vw;
  107. min-width: 360px;
  108. background-color: black;
  109. box-sizing: border-box;
  110. justify-content: space-around;
  111. }
  112. body > footer > a{
  113. color: white;
  114. align-self: center;
  115. text-decoration: none;
  116. }

总结,移动端页面的特点是头尾固定,中间主体滑动,在设计页面的时候,要将整个页面显示高度先设定好body{height:100vh;},再将头尾显示高度设定好,中间主体部分添加滑动轴main{overflow: auto;},一次完成基础的页面布置。注意两个单位:vh(显示高度),vw(显示宽度),二者都是百分比单位,是当前页面百分比。

Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:前端的作业先放放, 假期再补, 先跟上php的课程
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