PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

博客列表 > flex和grid演练

flex和grid演练

一个好人
一个好人 原创
2023年03月18日 18:47:25 440浏览
  1. <header>
  2. <nav>
  3. <a href="">首页</a>
  4. <a href="">市场营销</a>
  5. <a href="">生产控制</a>
  6. <a href="">技术研发</a>
  7. <a href="">品质管理</a>
  8. <a href="">工艺文件</a>
  9. </nav>
  10. <button>登录</button>
  11. </header>
  12. <style>
  13. header{
  14. height: 50px;
  15. background-color: #333;
  16. padding: 0 2em;
  17. display: flex;
  18. place-content: space-between;
  19. }
  20. nav{
  21. display: flex;
  22. text-align: center;
  23. line-height: 50px;
  24. }
  25. nav a{
  26. color: #ccc;
  27. text-decoration: none;
  28. min-width: 7em;
  29. flex: 1;
  30. }
  31. nav a:hover{
  32. color: black;
  33. background-color: aqua;
  34. transition: 0.3s;
  35. font-size: 1.2rem;
  36. }
  37. header button{
  38. border: none;
  39. width: 5em;
  40. color:beige;
  41. background-color:cornflowerblue;
  42. font-size: 1rem;
  43. }
  44. header button:hover{
  45. cursor: pointer;
  46. background-color:aqua;
  47. transition: 0.3s;
  48. color: #000;
  49. }
  50. </style>

导航

  1. <style>
  2. .container{
  3. width: 500px;
  4. height: 150px;
  5. margin-left: 100px;
  6. text-align: center;
  7. display:grid;
  8. grid-template-columns: repeat(5, 1fr);
  9. grid-template-rows: repeat(5, 1fr);
  10. }
  11. .container>.item:first-child{
  12. grid-area: 1 / 1 / span 2 / span 5;
  13. background-color: aliceblue;
  14. }
  15. .container>.item:nth-child(2){
  16. grid-area: 3/2;
  17. }
  18. .container>.item:nth-child(3){
  19. grid-row: 4;
  20. grid-column: 2;
  21. }
  22. .container>.item:last-child{
  23. grid-area: 5/1/5/6;
  24. background-color: antiquewhite;
  25. }
  26. </style>

grid演练

总结:

学了flex和grid,感觉现在可以做一个主页框架了,细节要慢慢优化了,遇到不能实现的地方再查资料,还有就是项目没有倒角,看上去有点生硬。

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