Blogger Information
Blog 10
fans 0
comment 0
visits 4720
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
grid和flex布局实现右侧布局
P粉854918706
Original
580 people have browsed it

main.css代码

  1. main {
  2. font-size: 14px;
  3. }
  4. main .navs{
  5. display: grid;
  6. grid-template-columns: 160px 810px 190px;
  7. grid-template-rows: 400px 80px;
  8. gap:20px;
  9. place-content: center;
  10. margin: 10px 0 20px;
  11. }
  12. main .navs > * {
  13. background-color: #fff;
  14. border-radius: 12px;
  15. }
  16. main .navs .slider a img{
  17. width:100%;
  18. border-radius: 12px;
  19. }
  20. main .navs .left{
  21. padding: 20px 0;
  22. display: grid;
  23. place-items: center;
  24. }
  25. main .navs .left a{
  26. padding:10px 20px;
  27. }
  28. main .navs .left a:hover{
  29. border-radius: 20px;
  30. color:red;
  31. background-color: rgb(250,223,227);
  32. }
  33. main .navs .right{
  34. display:grid;
  35. grid-template-rows: 75px 75px 1fr;
  36. }
  37. main .navs .right .user{
  38. display:flex;
  39. place-content: space-evenly;
  40. place-items: center start;
  41. }
  42. main .navs .right .user li{
  43. display: grid;
  44. grid-template-columns: 40px 100px;
  45. grid-template-rows: repeat(2,25px);
  46. gap: 0 10px;
  47. place-items: center start;
  48. }
  49. main .navs .right .user li a:first-of-type{
  50. grid-row: span 2;
  51. }
  52. main .navs .right .user li a img{
  53. width:100%;
  54. border-radius: 50%;
  55. }
  56. main .navs .right .user li a{
  57. font-size: 14px;
  58. font-weight: bolder;
  59. }
  60. main .navs .right .user li a:hover,
  61. main .navs .right .list li a:hover{
  62. color:red;
  63. }
  64. main .navs .right .user li span{
  65. color:#999;
  66. }
  67. main .navs .right .title a{
  68. display: block;
  69. width:150px;
  70. height:34px;
  71. margin-left: 20px;
  72. margin-bottom: 30px;
  73. text-align: center;
  74. line-height: 34px;
  75. background-color: red;
  76. color: #fff;
  77. border-radius: 20px;
  78. }
  79. main .navs .right .list{
  80. display: grid;
  81. padding: 10px 20px 5px;
  82. }
  83. main .navs .right .list li:first-of-type>a{
  84. display: inline-block;
  85. width:31px;
  86. height:16px;
  87. line-height: 16px;
  88. border-radius: 2px;
  89. background-color: red;
  90. color:#fff;
  91. font-size: 12px;
  92. text-align: center;
  93. }
  94. main .navs .right .list li a{
  95. margin-left: 10px;
  96. color:#999;
  97. }
  98. main .navs .right .list .mid{
  99. display: flex;
  100. }
  101. main .navs .right .list .mid span{
  102. width:50px;
  103. }
  104. main .navs .bottom-left{
  105. display: grid;
  106. grid-column: span 2;
  107. grid-template-columns: 100px 1fr;
  108. }
  109. main .navs .bottom-left .desc{
  110. display: grid;
  111. padding:16px 0;
  112. place-items: center;
  113. }
  114. main .navs .bottom-left .desc span{
  115. font-size: 12px;
  116. color:#999;
  117. }
  118. main .navs .bottom-left .detail{
  119. display: flex;
  120. place-items: center;
  121. place-content: space-between;
  122. padding:20px;
  123. }
  124. main .navs .bottom-left .detail li{
  125. display: grid;
  126. grid-template-columns: 36px 85px;
  127. grid-template-rows: repeat(2,20px);
  128. gap: 0 10px;
  129. place-items: center start ;
  130. }
  131. main .navs .bottom-left .detail li img{
  132. width:100%;
  133. grid-row:span 2;
  134. }
  135. main .navs .bottom-left .detail li a{
  136. font-size: 14px;
  137. }
  138. main .navs .bottom-left .detail li a:hover{
  139. color:red;
  140. }
  141. main .navs .bottom-left .detail li span{
  142. font-size:12px;
  143. color:#999;
  144. }
  145. main .navs .bottom-right{
  146. display: flex;
  147. place-items: center;
  148. place-content: space-evenly;
  149. }
  150. main .navs .bottom-right li{
  151. display:grid;
  152. place-items: center;
  153. gap:8px 0;
  154. }
  155. main .navs .bottom-right li span.icon-logo-wechat,
  156. main .navs .bottom-right li span.icon-QQ-circle-fill{
  157. font-size:32px;
  158. color:#999;
  159. }
  160. main .navs .bottom-right li span:hover{
  161. cursor: pointer;
  162. }
  163. main .navs .bottom-right li a:hover{
  164. color:red;
  165. }
  166. main .navs .bottom-right li a{
  167. font-size: 12px;
  168. font-weight:bolder;
  169. color: #515151;
  170. }

这是case.html代码

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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>Document</title>
  8. <link rel="stylesheet" href="static/css/header.css" />
  9. <link rel="stylesheet" href="static/css/main.css">
  10. <link rel="stylesheet" href="static/font/iconfont.css" />
  11. </head>
  12. <body>
  13. <header>
  14. <div class="top">
  15. <div class="content">
  16. <div class="title">php中文网-程序员梦开始的地方</div>
  17. <div class="right">
  18. <a href="" class="iconfont icon-tixing-tianchong myicon"></a>
  19. <a href=""><img src="static/image/IMG_20210728_191104.jpg" alt="" /></a>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="navs">
  24. <div class="content">
  25. <a href=""><img src="static/image/logo.png" alt="" /></a>
  26. <nav>
  27. <a href="" class="active">首页</a>
  28. <a href="">教学视频</a>
  29. <a href="">学习路径</a>
  30. <a href="">社区问答</a>
  31. </nav>
  32. <div class="search">
  33. <input type="search" placeholder="输入关键字" />
  34. <span class="iconfont icon-fangdajing1"></span>
  35. </div>
  36. </div>
  37. </div>
  38. </header>
  39. <main>
  40. <div class="navs">
  41. <div class="left">
  42. <a href="">php开发</a>
  43. <a href="">大前端</a>
  44. <a href="">后端开发</a>
  45. <a href="">数据库</a>
  46. <a href="">移动端</a>
  47. <a href="">运维开发</a>
  48. <a href="">UI设计</a>
  49. <a href="">计算机基础</a>
  50. </div>
  51. <div class="slider">
  52. <a href=""><img src="static/image/736f835f2907e552e0257e59ec635a10_62fdcfb67b3b8383.png" alt=""></a>
  53. </div>
  54. <div class="right">
  55. <div class="user">
  56. <li>
  57. <a href=""><img src="static/image/user_avatar.jpg" alt=""></a>
  58. <a href="">P粉8549...</a>
  59. <span>p豆 18</span>
  60. </li>
  61. </div>
  62. <div class="title">
  63. <a href="">我的学习</a>
  64. <hr style="height:1px;border:none;border-top:1px solid #eee">
  65. </div>
  66. <div class="list">
  67. <li>问答社区<a href="">答疑</a></li>
  68. <li class="mid">
  69. <span>头条</span>
  70. <a href="">9个vue3开发技巧,提升效率帮</a>
  71. </li>
  72. <li>福利<a href="">限时折扣>></a></li>
  73. <li>新班<a href="">21期PHP直播班</a></li>
  74. <li>招募<a href="">课程合作计划</a></li>
  75. <li>公告<a href="">APP上线啦</a></li>
  76. </div>
  77. </div>
  78. <div class="bottom-left">
  79. <div class="desc">
  80. <div class="title">学习路径</div>
  81. <span>全部7个&gt</span>
  82. </div>
  83. <div class="detail">
  84. <li onclick="">
  85. <img src="static/image/dgjj.png" alt="">
  86. <a href="">独孤九剑</a>
  87. <span>9门课程</span>
  88. </li>
  89. <li onclick="">
  90. <img src="static/image/phpkjkf.png" alt="">
  91. <a href="">玉女心经</a>
  92. <span>5门课程</span>
  93. </li>
  94. <li onclick="">
  95. <img src="static/image/phpksrm.png" alt="">
  96. <a href="">天龙八部</a>
  97. <span>3门课程</span>
  98. </li>
  99. <li onclick="">
  100. <img src="static/image/tlbb.png" alt="">
  101. <a href="">自学指南</a>
  102. <span>19门课程</span>
  103. </li>
  104. <li onclick="">
  105. <img src="static/image/ynxj.png" alt="">
  106. <a href="">趣味闯关</a>
  107. <span>22门课程</span>
  108. </li>
  109. </div>
  110. </div>
  111. <div class="bottom-right">
  112. <li>
  113. <span class="iconfont icon-logo-wechat"></span>
  114. <a href="">官方公众号</a>
  115. </li>
  116. <li>
  117. <span class="iconfont icon-QQ-circle-fill"></span>
  118. <a href="">官方QQ群</a>
  119. </li>
  120. </div>
  121. </div>
  122. </main>
  123. </body>
  124. </html>

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
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