博客列表 >flex布局——京东商城头部+导航

flex布局——京东商城头部+导航

小雨丶
小雨丶原创
2021年01月01日 15:42:37820浏览

HTML部分

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=`, initial-scale=1.0">
  6. <title>Document</title>
  7. <link rel="stylesheet" href="fonts/iconfont.css">
  8. <link rel="stylesheet" href="css/index.css">
  9. </head>
  10. <body>
  11. <div class="header">
  12. <div class="menu iconfont icon-caidan"></div>
  13. <div class="int">
  14. <span>JD</span>
  15. <i class="iconfont icon-sousuo"></i>
  16. <input type="text" placeholder="t恤">
  17. </div>
  18. <div class="login">登录</div>
  19. </div>
  20. <div class="main">
  21. <nav>
  22. <a href="">
  23. <img src="https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/125678/35/5947/4868/5efbf28cEbf04a25a/e2bcc411170524f0.png" alt="图片">
  24. <div>京东超市</div>
  25. </a>
  26. <a href="">
  27. <img src="https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/125678/35/5947/4868/5efbf28cEbf04a25a/e2bcc411170524f0.png" alt="图片">
  28. <div>京东超市</div>
  29. </a>
  30. <a href="">
  31. <img src="https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/125678/35/5947/4868/5efbf28cEbf04a25a/e2bcc411170524f0.png" alt="图片">
  32. <div>京东超市</div>
  33. </a>
  34. <a href="">
  35. <img src="https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/125678/35/5947/4868/5efbf28cEbf04a25a/e2bcc411170524f0.png" alt="图片">
  36. <div>京东超市</div>
  37. </a>
  38. <a href="">
  39. <img src="https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/125678/35/5947/4868/5efbf28cEbf04a25a/e2bcc411170524f0.png" alt="图片">
  40. <div>京东超市</div>
  41. </a>
  42. <a href="">
  43. <img src="https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/125678/35/5947/4868/5efbf28cEbf04a25a/e2bcc411170524f0.png" alt="图片">
  44. <div>京东超市</div>
  45. </a>
  46. <a href="">
  47. <img src="https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/125678/35/5947/4868/5efbf28cEbf04a25a/e2bcc411170524f0.png" alt="图片">
  48. <div>京东超市</div>
  49. </a>
  50. <a href="">
  51. <img src="https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/125678/35/5947/4868/5efbf28cEbf04a25a/e2bcc411170524f0.png" alt="图片">
  52. <div>京东超市</div>
  53. </a>
  54. <a href="">
  55. <img src="https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/125678/35/5947/4868/5efbf28cEbf04a25a/e2bcc411170524f0.png" alt="图片">
  56. <div>京东超市</div>
  57. </a>
  58. <a href="">
  59. <img src="https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/125678/35/5947/4868/5efbf28cEbf04a25a/e2bcc411170524f0.png" alt="图片">
  60. <div>京东超市</div>
  61. </a>
  62. </nav>
  63. </div>
  64. <div class="footer">footer</div>
  65. </body>
  66. </html>

CSS部分

  1. *{
  2. margin:0;
  3. padding:0;
  4. box-sizing:border-box;
  5. }
  6. li{
  7. list-style:none;
  8. }
  9. a{
  10. color:#7b7b7b;
  11. text-decoration:none;
  12. }
  13. body{
  14. background-color:#f6f6f6;
  15. }
  16. html{
  17. font-size:10px;
  18. }
  19. @import 'reset.css';
  20. .header{
  21. background-color:#e43130;
  22. color:white;
  23. height:4rem;
  24. display:flex;
  25. align-items:center;
  26. text-align:center;
  27. font-size:1.4rem;
  28. position:fixed;
  29. top:0;
  30. left:0;
  31. right:0;
  32. z-index:2;
  33. }
  34. .menu,.login{
  35. flex:1;
  36. height:3rem;
  37. line-height: 3rem;
  38. }
  39. .int{
  40. flex:6;
  41. height:3rem;
  42. line-height: 3rem;
  43. background-color:white;
  44. border-radius:3rem;
  45. display:flex;
  46. align-items:center;
  47. }
  48. .int span{
  49. font-size:2rem;
  50. height:2rem;
  51. line-height: 2rem;
  52. color:red;
  53. font-weight:800;
  54. flex:0 1 4rem;
  55. border-right:1px solid #999;
  56. }
  57. .int i{
  58. color:#999;
  59. flex:0 1 4rem;
  60. }
  61. .int input{
  62. flex:4;
  63. border:none;
  64. border-radius:3rem;
  65. outline:none;
  66. }
  67. .main{
  68. position:absolute;
  69. top:4.4rem;
  70. bottom:4.4rem;
  71. left:0;
  72. right:0;
  73. background:#007aff;
  74. }
  75. /*nav导航*/
  76. nav{
  77. display:flex;
  78. flex-flow:row wrap;
  79. text-align:center;
  80. background-color:white;
  81. margin: 0 1rem;
  82. border-radius:2rem;
  83. }
  84. nav a{
  85. width:20%;
  86. padding:1rem;
  87. }
  88. nav a img{
  89. width:4rem;
  90. }
  91. .footer{
  92. color:#666;
  93. background-color:#fafafa;
  94. height:4.4rem;
  95. box-shadow:0 0 3px #999;
  96. position:fixed;
  97. bottom:0;
  98. left:0;
  99. right:0;
  100. z-index:99;
  101. }
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议