博客列表 >项目在网格单元和容器中对齐方式、防php.cn首页布局

项目在网格单元和容器中对齐方式、防php.cn首页布局

Y的博客
Y的博客原创
2021年01月03日 21:54:16643浏览

一、项目在网格单元和容器中对齐的相关属性实例演示

  1. 项目在网格单元中的对齐方式

    1. /* 1. 设置容器中的“所有项目”在网格单元中的对齐方式 */
    2. .container {
    3. /* place-items: 垂直方向 水平方向; */
    4. /* 垂直居上,水平居中 */
    5. place-items: start center;
    6. /* 垂直居中对齐 */
    7. place-items: center center;
    8. /* 简写,两个值一样的时候可以简写 */
    9. place-items: center;
    10. /* 垂直居下,水平居右 */
    11. place-items: end end;
    12. /* 垂直居上,水平居右 */
    13. place-items: start end;
    14. /* normal */
    15. place-items: normal center;
    16. /* normal当成auto的同义词 */
    17. place-items: auto center;
    18. /* 继承*/
    19. /* place-items: inherit; */
    20. /* 初始化 */
    21. /* place-items: initial; */
    22. /* 清楚 */
    23. /* place-items: unset; */
    24. /* 拉伸,取消项目的固定尺寸才可以看到效果 */
    25. /* place-items: stretch; */
    26. }
    27. /* 2.设置容器中的单个项目对齐方式用:place-self */
    28. .container>.item:nth-of-type(5) {
    29. background-color: lightsalmon;
    30. /* 垂直向上,水平居左 */
    31. place-self: start ;
    32. /* 垂直水平居中 */
    33. place-self: center;
    34. /* 垂直向下,水平居右 */
    35. place-self: end;
    36. }
    37. /* 单元格有两种表现形式:单元格、网格区域 */
    38. .container>.item:nth-of-type(5) {
    39. grid-area: span 2 / span 2;;
    40. place-self: center;
    41. }
  2. 项目在网格容器中的对齐方式
    1. /* place-content: 垂直方向 水平方向 */
    2. .container {
    3. /* 两端对齐 */
    4. place-content: space-between;
    5. /* 分散对齐 */
    6. place-content: space-around;
    7. /* 平均对齐 */
    8. place-content: space-evenly;
    9. }

    二、 防php.cn首页

    首页
  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. <title>防php中文网</title>
  7. <link rel="stylesheet" href="main.css">
  8. <link rel="stylesheet" href="../122501/css/font_edw7fy4dl8/iconfont.css">
  9. </head>
  10. <body>
  11. <header>
  12. <div class="logo">
  13. <a href="php.cn"><img src="../122501/img/logo.png" alt=""></a>
  14. </div>
  15. <div class="header-top">
  16. <a href="">首页</a>
  17. <a href="">视频教程</a>
  18. <a href="">入门教程</a>
  19. <a href="">社区问答</a>
  20. <a href="">技术文章</a>
  21. <a href="">资源下载</a>
  22. <a href="">编程词典</a>
  23. <a href="">工具下载</a>
  24. <a href="">PHP培训</a>
  25. </div>
  26. <span class="iconfont icon-laba"></span>
  27. <div class="butt">
  28. <a href="php.cn"><img src="../122501/img/fdeb3f55f550059558a173a32693af17.jpg" alt=""></a>
  29. </div>
  30. </header>
  31. <!-- 主体 -->
  32. <div class="main">
  33. <div class="main-top">
  34. <!-- 左侧菜单 -->
  35. <div class="menus">
  36. <div>
  37. <a href="">PHP开发</a>
  38. <a>&gt</a>
  39. </div>
  40. <div>
  41. <a href="">前端开发</a>
  42. <a>&gt</a>
  43. </div>
  44. <div>
  45. <a href="">服务器开发</a>
  46. <a>&gt</a>
  47. </div>
  48. <div>
  49. <a href="">移动开发</a>
  50. <a>&gt</a>
  51. </div>
  52. <div>
  53. <a href="">数据库 </a>
  54. <a>&gt</a>
  55. </div>
  56. <div>
  57. <a href="">服务器运维</a>
  58. <a>&gt</a>
  59. </div>
  60. <div>
  61. <a href="">在线工具箱</a>
  62. <a>&gt</a>
  63. </div>
  64. <div>
  65. <a href="">常用类库</a>
  66. <a>&gt</a>
  67. </div>
  68. </div>
  69. <!-- 头部菜单 -->
  70. <div class="navs">
  71. <li><a href="">PHP头条</a></li>
  72. <li><a href="">独孤九剑</a></li>
  73. <li><a href="">学习路线</a></li>
  74. <li><a href="">在线工具</a></li>
  75. <li><a href="">趣味课堂</a></li>
  76. <li><a href="">社区问答</a></li>
  77. <li><a href="">课程直播</a></li>
  78. <li><input type="text" placeholder="输入关键词搜索"></li>
  79. </div>
  80. <!-- 轮播图 -->
  81. <div class="slider">
  82. <img src="../122501/img/5fb478a8e82cb116.jpg" alt="">
  83. </div>
  84. <!-- 底部菜单推荐 -->
  85. <ul class="course">
  86. <li>
  87. <a href=""><img src="../122501/img/index_yunv.jpg" alt=""></a>
  88. </li>
  89. <li>
  90. <a href=""><img src="../122501/img/index_php_item2_.png" alt=""></a>
  91. </li>
  92. <li>
  93. <a href=""><img src="../122501/img/index_php_item3.jpg" alt=""></a>
  94. </li>
  95. <li>
  96. <a href=""><img src="../122501/img/index_php_new4.jpg" alt=""></a>
  97. </li>
  98. </ul>
  99. </div>
  100. <!-- 课程列表区 -->
  101. <div class="main-courses">
  102. <h3>&lt;\&gt;php入门精品课程&lt;\&gt;</h3>
  103. <ul class="course-list">
  104. <li>
  105. <a href=""><img src="../122501/img/index_learn_middel.jpg" alt=""></a>
  106. </li>
  107. <li>
  108. <a href=""><img src="../122501/img/5a1e28a9aa79e911.jpg" alt=""></a>
  109. <a href="">编程学习方法分享直播公益课</a>
  110. </li>
  111. <li>
  112. <a href=""><img src="../122501/img/5a1e2953da3c4679.jpg" alt=""></a>
  113. <a href="">编程学习方法分享直播公益课</a>
  114. </li>
  115. <li>
  116. <a href=""><img src="../122501/img/5a1e2953da3c4679.jpg" alt=""></a>
  117. <a href="">编程学习方法分享直播公益课</a>
  118. </li>
  119. <li>
  120. <a href=""><img src="../122501/img/5a9fb97057b15707.jpeg" alt=""></a>
  121. <a href="">编程学习方法分享直播公益课</a>
  122. </li>
  123. <li>
  124. <a href=""><img src="../122501/img/5a40a5ac656b3153.jpg" alt=""></a>
  125. <a href="">编程学习方法分享直播公益课</a>
  126. </li>
  127. <li>
  128. <a href=""><img src="../122501/img/5a161e2d393cb585.jpg" alt=""></a>
  129. <a href="">编程学习方法分享直播公益课</a>
  130. </li>
  131. <li>
  132. <a href=""><img src="../122501/img/5a162a835bd25655.jpg" alt=""></a>
  133. <a href="">编程学习方法分享直播公益课</a>
  134. </li>
  135. <li>
  136. <a href=""><img src="../122501/img/5a162ad093ab8241.jpg" alt=""></a>
  137. <a href="">编程学习方法分享直播公益课</a>
  138. </li>
  139. <li>
  140. <a href=""><img src="../122501/img/5a372b552a2c4233.jpg" alt=""></a>
  141. <a href="">编程学习方法分享直播公益课</a>
  142. </li>
  143. <li>
  144. <a href=""><img src="../122501/img/5a372e0cb6736575.jpg" alt=""></a>
  145. <a href="">编程学习方法分享直播公益课</a>
  146. </li>
  147. <li>
  148. <a href=""><img src="../122501/img/5a699f1b2da2b398.jpg" alt=""></a>
  149. <a href="">编程学习方法分享直播公益课</a>
  150. </li>
  151. <li>
  152. <a href=""><img src="../122501/img/5a3728258bf9f213.jpg" alt=""></a>
  153. <a href="">编程学习方法分享直播公益课</a>
  154. </li>
  155. <li>
  156. <a href=""><img src="../122501/img/5a6848743a2b9344.jpg" alt=""></a>
  157. <a href="">编程学习方法分享直播公益课</a>
  158. </li>
  159. </ul>
  160. </div>
  161. <!-- 进阶学习路径 -->
  162. <div class="main-courses">
  163. <h3>&lt;\&gt;php进阶学习路径&lt;\&gt;</h3>
  164. <ul class="course-list">
  165. <li>
  166. <a href=""><img src="../122501/img/index_learn_middel.jpg" alt=""></a>
  167. </li>
  168. <li>
  169. <a href=""><img src="../122501/img/5a1e28a9aa79e911.jpg" alt=""></a>
  170. <a href="">编程学习方法分享直播公益课</a>
  171. </li>
  172. <li>
  173. <a href=""><img src="../122501/img/5a1e2953da3c4679.jpg" alt=""></a>
  174. <a href="">编程学习方法分享直播公益课</a>
  175. </li>
  176. <li>
  177. <a href=""><img src="../122501/img/5a1e2953da3c4679.jpg" alt=""></a>
  178. <a href="">编程学习方法分享直播公益课</a>
  179. </li>
  180. <li>
  181. <a href=""><img src="../122501/img/5a9fb97057b15707.jpeg" alt=""></a>
  182. <a href="">编程学习方法分享直播公益课</a>
  183. </li>
  184. <li>
  185. <a href=""><img src="../122501/img/5a40a5ac656b3153.jpg" alt=""></a>
  186. <a href="">编程学习方法分享直播公益课</a>
  187. </li>
  188. <li>
  189. <a href=""><img src="../122501/img/5a161e2d393cb585.jpg" alt=""></a>
  190. <a href="">编程学习方法分享直播公益课</a>
  191. </li>
  192. <li>
  193. <a href=""><img src="../122501/img/5a162a835bd25655.jpg" alt=""></a>
  194. <a href="">编程学习方法分享直播公益课</a>
  195. </li>
  196. <li>
  197. <a href=""><img src="../122501/img/5a162ad093ab8241.jpg" alt=""></a>
  198. <a href="">编程学习方法分享直播公益课</a>
  199. </li>
  200. <li>
  201. <a href=""><img src="../122501/img/5a372b552a2c4233.jpg" alt=""></a>
  202. <a href="">编程学习方法分享直播公益课</a>
  203. </li>
  204. <li>
  205. <a href=""><img src="../122501/img/5a372e0cb6736575.jpg" alt=""></a>
  206. <a href="">编程学习方法分享直播公益课</a>
  207. </li>
  208. <li>
  209. <a href=""><img src="../122501/img/5a699f1b2da2b398.jpg" alt=""></a>
  210. <a href="">编程学习方法分享直播公益课</a>
  211. </li>
  212. <li>
  213. <a href=""><img src="../122501/img/5a3728258bf9f213.jpg" alt=""></a>
  214. <a href="">编程学习方法分享直播公益课</a>
  215. </li>
  216. <li>
  217. <a href=""><img src="../122501/img/5a6848743a2b9344.jpg" alt=""></a>
  218. <a href="">编程学习方法分享直播公益课</a>
  219. </li>
  220. </ul>
  221. </div>
  222. </div>
  223. <footer>
  224. <div class="footer-muen">
  225. <ul>
  226. <li>网站首页</li>
  227. <li>PHP视频</li>
  228. <li>PHP实战</li>
  229. <li>PHP代码</li>
  230. <li>PHP手册</li>
  231. <li>词条手记</li>
  232. <li>编程词典</li>
  233. <li>php培训</li>
  234. </ul>
  235. <a>
  236. php中文网:公益在线php培训,帮助PHP学习者快速成长!
  237. </a>
  238. <a>
  239. Copyright 2014-2020 https://www.php.cn/ All Rights Reserved | 苏州跃动光标网络科技有限公司 | 苏ICP备2020058653号-1 关于我们免责申明赞助与捐赠广告合作
  240. </a>
  241. </div>
  242. <div class="footer-img">
  243. <img src="../122501/img/phpcn_erwei.jpg" alt="">
  244. <img src="../122501/img/qq.jpg" alt="">
  245. </div>
  246. </footer>
  247. </body>
  248. </html>
样式
  1. * {
  2. padding: 0;
  3. margin: 0;
  4. box-sizing: border-box;
  5. list-style: none;
  6. text-decoration: none;
  7. }
  8. body {
  9. background-color: rgb(248, 244, 244);
  10. }
  11. header {
  12. height: 60px;
  13. background-color: #000;
  14. display: grid;
  15. grid-template-columns: 140px 1fr 60px 68px;
  16. padding: 0.5rem;
  17. place-content: space-around;
  18. margin-bottom: 1rem;
  19. }
  20. header>.log {
  21. display: grid;
  22. place-items: center;
  23. }
  24. header>.logo>a>img {
  25. width: 100%;
  26. }
  27. .header-top {
  28. display: grid;
  29. grid-template-columns: repeat(9, 96px);
  30. grid-template-rows: 60px;
  31. place-content: space-around;
  32. place-items: center;
  33. font-size: 1em;
  34. }
  35. a {
  36. color: #dad5d5;
  37. }
  38. header .iconfont {
  39. display: grid;
  40. color: white;
  41. font-size: 25px;
  42. place-self: center;
  43. opacity: 0.8;
  44. }
  45. .butt {
  46. display: grid;
  47. place-items: center;
  48. }
  49. .butt img {
  50. width: 45px;
  51. height: 45px;
  52. border-radius: 50%;
  53. }
  54. header .header-top a:hover {
  55. color: #fafafa;
  56. transition: 0.5s;
  57. border-bottom: 3px solid lightgreen;
  58. }
  59. header .header-top a:hover {
  60. cursor: pointer;
  61. opacity: 0.8;
  62. }
  63. /* 主体区 */
  64. .main .main-top {
  65. height: 530px;
  66. width: 1220px;
  67. margin-bottom: 30px;
  68. display: grid;
  69. grid-template-columns: 216px 1fr;
  70. grid-template-rows: 60px 1fr 120px;
  71. margin: auto;
  72. background-color: #fff;
  73. }
  74. /* 左侧导航区 */
  75. .main .main-top .menus {
  76. background-color: #2B333B;
  77. display: grid;
  78. grid-area: span 3;
  79. border-radius: 10px 0 0 10px;
  80. place-items: center start;
  81. padding: 2rem;
  82. }
  83. /* 顶部的导航区 */
  84. .main .main-top .navs {
  85. display: grid;
  86. grid-template-columns: repeat(8, 1fr);
  87. place-items: center;
  88. border-radius: 0 10px 0 0;
  89. color: black;
  90. font-size: 15px;
  91. background-color: #fff;
  92. }
  93. .main .main-top .navs a {
  94. color: rgb(70, 66, 66);
  95. }
  96. .main .main-top .navs a:hover {
  97. transition: 0.5s;
  98. border-bottom: 3px solid lightgreen;
  99. cursor: pointer;
  100. opacity: 0.8;
  101. }
  102. .main .main-top .navs li>input {
  103. width: 250px;
  104. height: 40px;
  105. /* border-radius: 2px; */
  106. }
  107. /* 推荐区 */
  108. .main .main-top .course {
  109. padding: 0.5rem;
  110. display: grid;
  111. grid-template-columns: repeat(4, 1fr);
  112. }
  113. .main .main-top .course a img {
  114. border-radius: 10px;
  115. }
  116. /* 课程列表区 */
  117. .main .main-courses {
  118. width: 1200px;
  119. height: 646px;
  120. padding: 15px;
  121. margin: 30px auto;
  122. display: grid;
  123. grid-template-rows: 50px 1fr;
  124. gap: 10px;
  125. border-radius: 10px;
  126. }
  127. .main .main-courses h3 {
  128. text-align: center;
  129. margin-bottom: 30px;
  130. color: #444444;
  131. }
  132. .main .main-courses .course-list {
  133. display: grid;
  134. grid-template-columns: repeat(5, 1fr);
  135. grid-template-rows: repeat(3, 1fr);
  136. gap: 10px;
  137. }
  138. .main .main-courses .course-list img {
  139. border-radius: 10px;
  140. width: 217px;
  141. }
  142. .main .main-courses .course-list * {
  143. color: rgb(75, 70, 70);
  144. }
  145. .main .main-courses .course-list li:first-of-type {
  146. grid-area: span 2;
  147. }
  148. footer {
  149. height: 174px;
  150. background-color: #393D49;
  151. display: grid;
  152. grid-template-columns: repeat(2, 1fr);
  153. grid-template-rows: repeat(3, 1fr);
  154. place-content: space-around;
  155. padding: 30px;
  156. }
  157. footer .footer-muen {
  158. color: rgb(221, 221, 221);
  159. font-size: 12px;
  160. display: grid;
  161. grid-template-columns: repeat(1, 1fr);
  162. grid-template-rows: repeat(3, 1fr);
  163. place-items: start;
  164. padding-left: 30px;
  165. }
  166. footer .footer-muen ul {
  167. display: grid;
  168. grid-template-columns: repeat(8, 1fr);
  169. }
  170. footer .footer-img {
  171. display: grid;
  172. grid-template-columns: repeat(2, 200px);
  173. place-items: center;
  174. }
  175. footer .footer-img img {
  176. width: 100px;
  177. place-self: center;
  178. }
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议