博客列表 >使用flex和girl布局仿PHP中文网部分静态页面

使用flex和girl布局仿PHP中文网部分静态页面

吴长清
吴长清原创
2022年07月15日 16:18:20565浏览

效果图:

HTML代码块

  1. <body>
  2. <!-- 页眉 -->
  3. <header>
  4. <div class="top">
  5. <div class="content">
  6. <span>php中文网-程序员梦开始的地方</span>
  7. <div class="login">
  8. <a href="" class="iconfont icon-tixingtianchong"></a>
  9. <a><img src="static/images/user-pic.jpeg" alt="" /></a>
  10. </div>
  11. </div>
  12. </div>
  13. <div class="bottom">
  14. <div class="content">
  15. <a href="#"><img src="static/images/logo.png" alt="" /></a>
  16. <nav class="navs">
  17. <a href="#" class="item">首页</a>
  18. <a href="#" class="item">视频教程</a>
  19. <a href="#" class="item">学习路径</a>
  20. <a href="#" class="item">PHP培训</a>
  21. <a href="#" class="item">资源下载</a>
  22. <a href="#" class="item">技术文章</a>
  23. <a href="#" class="item">社区</a>
  24. <a href="#" class="item">APP下载</a>
  25. </nav>
  26. <div class="search">
  27. <input type="search" placeholder="请输入关键字" />
  28. <span class="iconfont icon-fangdajing1"></span>
  29. </div>
  30. </div>
  31. </div>
  32. </header>
  33. <!-- 主体内容 -->
  34. <main>
  35. <div class="navs">
  36. <div class="left">
  37. <a href="">php开发</a>
  38. <a href="">大前端</a>
  39. <a href="">后端开发</a>
  40. <a href="">数据库</a>
  41. <a href="">移动端</a>
  42. <a href="">运维开发</a>
  43. <a href="">UI设计</a>
  44. <a href="">计算机基础</a>
  45. </div>
  46. <div class="slider">
  47. <a href=""><img src="static/images/slider.jpeg" alt="" /></a>
  48. </div>
  49. <div class="right">
  50. <div class="userinfo">
  51. <img
  52. src="static/images/user-pic.jpeg" alt="" />
  53. <a href="#">朱老师</a>
  54. <span>p豆:1200</span>
  55. <div class="btn">
  56. <button>我的学习</button>
  57. </div>
  58. </div>
  59. <ul class="derail">
  60. <li onclick="">
  61. <span>问答社区</span>
  62. <a href="#"><span class="desc">答疑</span></a>
  63. </li>
  64. <li onclick="">
  65. <span>头条</span>
  66. <a href="#"><span>vue发展情况</span></a>
  67. </li>
  68. <li onclick="">
  69. <span>福利</span>
  70. <a href="#"><span>限时折扣</span></a>
  71. </li>
  72. <li onclick="">
  73. <span>新班</span>
  74. <a href="#"><span>20期PHP线上班</span></a>
  75. </li>
  76. <li onclick="">
  77. <span>招募</span>
  78. <a href="#"><span>课程合作计划</span></a>
  79. </li>
  80. <li onclick="">
  81. <span>公告</span>
  82. <a href="#"><span>App上线啦</span></a>
  83. </li>
  84. </ul>
  85. </div>
  86. <div class="bottom-left">
  87. <div class="desc">
  88. <div class="title">学习路径</div>
  89. <span>全部7个&gt;</span>
  90. </div>
  91. <ul class="detail">
  92. <li onclick="">
  93. <img src="static/images/dgjj.png" alt="" />
  94. <a href="">独孤九贱</a>
  95. <span>9门课程</span>
  96. </li>
  97. <li onclick="">
  98. <img src="static/images/ynxj.png" alt="" />
  99. <a href="">独孤九贱</a>
  100. <span>9门课程</span>
  101. </li>
  102. <li onclick="">
  103. <img src="static/images/tlbb.png" alt="" />
  104. <a href="">独孤九贱</a>
  105. <span>9门课程</span>
  106. </li>
  107. <li onclick="">
  108. <img src="static/images/phpkjkf.png" alt="" />
  109. <a href="">独孤九贱</a>
  110. <span>9门课程</span>
  111. </li>
  112. <li onclick="">
  113. <img src="static/images/phpksrm.png" alt="" />
  114. <a href="">独孤九贱</a>
  115. <span>9门课程</span>
  116. </li>
  117. </ul>
  118. </div>
  119. <div class="bottom-right">
  120. <div class="weixin">
  121. <span class="iconfont icon-weixin1"></span>
  122. <span>官方公众号</span>
  123. </div>
  124. <div class="qq">
  125. <span class="iconfont icon-QQ"></span>
  126. <span>官方QQ群</span>
  127. </div>
  128. </div>
  129. <div class="live">
  130. <div class="top">
  131. <span class="title">直播课</span>
  132. <a href="" class="more">更多></a>
  133. </div>
  134. <div class="bottom">
  135. <ul class="list">
  136. <li class="item">
  137. <img src="static/images/live/1.jpg" alt="" />
  138. <a href="#">
  139. 公益直播:PHP入门到实战--实现邮箱验证(队列发送邮件)
  140. </a>
  141. <span class="sp1">精彩回放</span>
  142. <span class="sp2">21215人观看</span>
  143. </li>
  144. <li class="item">
  145. <img src="static/images/live/2.jpg" alt="" />
  146. <a href="#"> 第二期_大前端线上班 </a>
  147. <span class="sp1">精彩回放</span>
  148. <span class="sp2">21215人观看</span>
  149. </li>
  150. <li class="item">
  151. <img src="static/images/live/3.png" alt="" />
  152. <a href="#"> 第二十期_前端开发 </a>
  153. <span class="sp1">精彩回放</span>
  154. <span class="sp2">21215人观看</span>
  155. </li>
  156. <li class="item"></li>
  157. </ul>
  158. </div>
  159. </div>
  160. </div>
  161. </main>
  162. <!-- 页脚 -->
  163. <footer></footer>
  164. </body>

css代码

  1. @import url(reset.css);
  2. /* 页眉 */
  3. /* 顶部 */
  4. body header .top {
  5. width: 100vw;
  6. height: 40px;
  7. background-color: #343434;
  8. }
  9. body header .top .content {
  10. width: 1200px;
  11. height: 40px;
  12. margin: 0 auto;
  13. display: flex;
  14. place-content: space-between;
  15. place-items: center;
  16. }
  17. body header .top .content span {
  18. width: 300px;
  19. color: rgba(206, 205, 205, 1);
  20. font-family: "微软雅黑";
  21. font-size: 14px;
  22. }
  23. body header .top .content .login {
  24. width: 100px;
  25. display: grid;
  26. grid-template-columns: repeat(2, 1fr);
  27. place-items: center;
  28. }
  29. body header .top .content .login .icon-tixingtianchong {
  30. color: #eee;
  31. font-size: larger;
  32. }
  33. body header .top .content .login img {
  34. width: 50%;
  35. border-radius: 50%;
  36. }
  37. /* 底部 */
  38. body header .bottom {
  39. width: 100vw;
  40. height: 90px;
  41. background-color: white;
  42. box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  43. }
  44. body header .bottom .content {
  45. width: 1200px;
  46. margin: 0 auto;
  47. display: grid;
  48. grid-template-columns: 140px 1fr 200px;
  49. grid-auto-rows: 90px;
  50. gap: 10px;
  51. place-items: center start;
  52. }
  53. body header .bottom .content img {
  54. width: 140px;
  55. margin-top: 3px;
  56. }
  57. body header .bottom .content .navs {
  58. display: flex;
  59. margin-left: 40px;
  60. }
  61. body header .bottom .content .navs a {
  62. padding: 0 10px;
  63. font-size: larger;
  64. }
  65. body header .bottom .content .navs a:first-of-type,
  66. body header .bottom .content .navs a:hover {
  67. color: red;
  68. font-weight: bold;
  69. }
  70. body header .bottom .content .search {
  71. display: flex;
  72. }
  73. body header .bottom .content .search input[type="search"] {
  74. border: none;
  75. background-color: #eee;
  76. width: 200px;
  77. height: 36px;
  78. border-radius: 20px;
  79. padding-left: 10px;
  80. outline: none;
  81. }
  82. body header .bottom .content .search .icon-fangdajing1 {
  83. font-size: 22px;
  84. left: -40px;
  85. top: 5px;
  86. color: rgb(168, 167, 167);
  87. position: relative;
  88. }
  89. body header .bottom .content .search .icon-fangdajing1:hover {
  90. color: red;
  91. cursor: pointer;
  92. }
  93. body main .navs {
  94. /* 2行3列 */
  95. display: grid;
  96. grid-template-rows: 400px 80px;
  97. grid-template-columns: 160px 810px 190px;
  98. gap: 20px;
  99. place-content: center;
  100. margin: 30px 0;
  101. }
  102. /* 统一样式,完成后可看到基本框架 */
  103. body main .navs > * {
  104. background-color: #fff;
  105. border-radius: 20px;
  106. }
  107. /* 底部左边占2列 */
  108. body main .navs .bottom-left {
  109. grid-column: span 2;
  110. }
  111. /* 整体布局完成,剩下就是细节了 */
  112. /* 上部左边导航 */
  113. body main .navs .left {
  114. padding: 20px 0;
  115. /* grid: 默认每个项目都是"块级", 垂直排列 */
  116. /* flex: 默认每个项目都是"行内块级", 水平排列 */
  117. display: grid;
  118. /* 当前项目在每个网络单元中, 垂直,水平均居中 */
  119. /* place-items: 垂直方向 水平方向; */
  120. place-items: center;
  121. }
  122. body main .navs .left a {
  123. padding: 10px 20px;
  124. }
  125. body main .navs .left a:hover {
  126. border-radius: 20px;
  127. color: red;
  128. background-color: rgb(250, 223, 227);
  129. }
  130. /* 轮播图,单图模拟 */
  131. body main .navs .slider img {
  132. width: 100%;
  133. border-radius: 20px;
  134. }
  135. /* 底部左侧 */
  136. body main .navs .bottom-left {
  137. display: grid;
  138. grid-template-columns: 100px 1fr;
  139. }
  140. body main .navs .bottom-left .desc {
  141. padding: 16px 0;
  142. display: grid;
  143. place-items: center;
  144. font-size: 14px;
  145. }
  146. body main .navs .bottom-left .desc span {
  147. font-size: 12px;
  148. color: #999;
  149. }
  150. body main .navs .bottom-left .detail {
  151. display: flex;
  152. place-items: center;
  153. place-content: space-between;
  154. padding: 20px;
  155. }
  156. body main .navs .bottom-left .detail li {
  157. display: grid;
  158. grid-template-columns: 36px 85px;
  159. grid-template-columns: repeat(2, 36);
  160. gap: 0 10px;
  161. place-items: center start;
  162. }
  163. body main .navs .bottom-left .detail img {
  164. width: 100%;
  165. grid-row: span 2;
  166. }
  167. body main .navs .bottom-left .detail li a {
  168. font-size: 14px;
  169. }
  170. body main .navs .bottom-left .detail li a:hover {
  171. color: red;
  172. }
  173. body main .navs .bottom-left .detail li span {
  174. font-size: 12px;
  175. color: #999;
  176. }
  177. /* 用户信息 */
  178. body main .navs .right {
  179. display: grid;
  180. grid-template-rows: 140px 1fr;
  181. place-items: center;
  182. }
  183. body main .navs .right .userinfo {
  184. width: 100%;
  185. display: grid;
  186. grid-template-columns: 90px 100px;
  187. grid-template-rows: 30px 30px 70px;
  188. }
  189. body main .navs .right .userinfo img {
  190. grid-row: span 2;
  191. border-radius: 40px;
  192. place-self: center;
  193. }
  194. body main .navs .right .userinfo a {
  195. place-self: center start;
  196. }
  197. body main .navs .right .userinfo span {
  198. color: rgb(121, 120, 120);
  199. font-size: 12px;
  200. }
  201. body main .navs .right .userinfo a:hover {
  202. color: red;
  203. }
  204. body main .navs .right .userinfo a {
  205. font-family: "微软雅黑";
  206. font-weight: bold;
  207. font-size: 12px;
  208. color: black;
  209. }
  210. body main .navs .right .userinfo .btn {
  211. width: 100%;
  212. height: 70px;
  213. grid-column: span 2;
  214. border-bottom: 1px solid rgba(146, 145, 145, 0.3);
  215. }
  216. body main .navs .right .userinfo .btn button {
  217. border-radius: 40px;
  218. width: 80%;
  219. height: 30px;
  220. margin-top: 15px;
  221. border: none;
  222. background-color: red;
  223. font-weight: bold;
  224. cursor: pointer;
  225. margin-left: 10%;
  226. color: #fff;
  227. }
  228. body main .navs .right .derail {
  229. margin: auto;
  230. font-size: 14px;
  231. }
  232. body main .navs .right .derail li {
  233. display: grid;
  234. grid-template-columns: 60px 100px;
  235. grid-auto-rows: 30px;
  236. }
  237. body main .navs .right .derail li span {
  238. place-self: center;
  239. font-weight: bold;
  240. }
  241. body main .navs .right .derail li a span {
  242. font-weight: lighter;
  243. color: rgb(151, 150, 150);
  244. }
  245. body main .navs .right .derail li:first-of-type a span {
  246. display: block;
  247. width: 40px;
  248. text-align: center;
  249. background-color: red;
  250. color: #fff;
  251. margin-left: 10px;
  252. }
  253. body main .navs .right .derail li a {
  254. place-self: center start;
  255. }
  256. /* 底部右边 */
  257. body main .navs .bottom-right {
  258. display: flex;
  259. place-content: space-around;
  260. }
  261. body main .navs .bottom-right .weixin,
  262. body main .navs .bottom-right .qq {
  263. display: grid;
  264. place-items: center;
  265. font-weight: bold;
  266. }
  267. body main .navs .bottom-right .weixin span:last-of-type,
  268. body main .navs .bottom-right .qq span:last-of-type {
  269. font-size: 12px;
  270. place-self: start center;
  271. }
  272. body main .navs .bottom-right .weixin .icon-weixin1,
  273. body main .navs .bottom-right .qq .icon-QQ {
  274. display: inline-block;
  275. font-size: 16px;
  276. width: 30px;
  277. height: 30px;
  278. text-align: center;
  279. line-height: 30px;
  280. color: #fff;
  281. background-color: #aaa;
  282. border-radius: 30px;
  283. }
  284. /* 直播课板块 */
  285. body main .navs .live {
  286. width: 1200px;
  287. display: flex;
  288. flex-flow: column nowrap;
  289. background-color: rgb(243, 245, 247);
  290. }
  291. /* 顶部 */
  292. body main .navs .live .top {
  293. width: 100%;
  294. height: 32px;
  295. display: flex;
  296. place-content: space-between;
  297. place-items: center;
  298. }
  299. body main .navs .live .top .title {
  300. font-size: 22px;
  301. font-weight: bold;
  302. color: #333333;
  303. }
  304. body main .navs .live .top .more {
  305. margin-right: 5px;
  306. font-size: 14px;
  307. color: #999999;
  308. }
  309. /* 底部 */
  310. body main .navs .live .bottom {
  311. width: 100%;
  312. margin-top: 10px;
  313. }
  314. body main .navs .live .bottom .list {
  315. display: flex;
  316. place-content: space-between;
  317. }
  318. body main .navs .live .bottom .list .item {
  319. width: 280px;
  320. height: 260px;
  321. background-color: white;
  322. border-radius: 10px;
  323. display: grid;
  324. grid-template-columns: 140px 140px;
  325. grid-template-rows: 160px 50px 50px;
  326. place-content: start center;
  327. }
  328. body main .navs .live .bottom .list img {
  329. width: 280px;
  330. height: 160px;
  331. border-radius: 10px 10px 0 0;
  332. grid-column: span 2;
  333. }
  334. body main .navs .live .bottom .list a {
  335. width: 245px;
  336. margin: auto;
  337. grid-column: span 2;
  338. color: #333333;
  339. }
  340. body main .navs .live .top .more:hover,
  341. body main .navs .live .bottom .list a:hover{
  342. color: red;
  343. }
  344. body main .navs .live .bottom .list .sp1 {
  345. width: 120px;
  346. height: 18px;
  347. margin-left: 18px;
  348. font-size: 14px;
  349. place-self: center start;
  350. }
  351. body main .navs .live .bottom .list .sp2 {
  352. width: 100px;
  353. height: 18px;
  354. font-size: 14px;
  355. place-self: center end;
  356. color: #aaa;
  357. }
上一条:9个grid属性下一条:grid的9个属性
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议