Blogger Information
Blog 14
fans 0
comment 0
visits 23820
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
使用Grid / Flex , 编写淘宝网PC端首页布局
逍遥php
Original
490 people have browsed it

淘宝首页布局(页眉)

html

  1. <!-- 1.页眉 -->
  2. <header>
  3. <!-- 1.LOGO -->
  4. <a class="logo" href="https://m.taobao.com"><img src="../1028/images/taobao.png"></a>
  5. <!-- 2.搜索框 -->
  6. <a href="" class="search">
  7. <span>寻找宝贝店铺</span>
  8. <span>搜索</span>
  9. </a>
  10. <!-- 3.签到图标 -->
  11. <a href="" class="iconfont icon-qiandao-xuanzhong"></a>
  12. </header>
  13. <!-- 2.主体 -->
  14. <main>主体</main>
  15. <!-- 3.页脚 -->
  16. <footer>页脚</footer>

css

  1. * {
  2. margin: 0;
  3. padding: 0;
  4. box-sizing: border-box;
  5. }
  6. header,
  7. footer {
  8. height: 50px;
  9. /* 固定定位 */
  10. position: fixed;
  11. }
  12. header {
  13. top: 0;
  14. left: 0;
  15. right: 0;
  16. z-index: 1;
  17. }
  18. footer {
  19. background-color: lightblue;
  20. bottom: 0;
  21. left: 0;
  22. right: 0;
  23. }
  24. main {
  25. background-color: yellow;
  26. min-height: 2000px;
  27. position: relative;
  28. top: 50px;
  29. }
  30. /* 页眉布局 */
  31. header {
  32. display: grid;
  33. /* 1行3列 */
  34. grid-template-columns: 0.58rem 1fr 0.33rem;
  35. grid-auto-rows: 0.5rem;
  36. place-items: center;
  37. gap: 0.1rem;
  38. }
  39. header a.logo {
  40. padding-left: 0.1rem;
  41. }
  42. header a.search {
  43. width: 100%;
  44. border: 2px solid orangered;
  45. height: 0.3rem;
  46. border-radius: 0.3rem;
  47. /* grid:整体 flex:细节 */
  48. display: flex;
  49. place-content: space-between;
  50. place-items: center;
  51. }
  52. header a.search span:first-of-type {
  53. padding-left: 10px;
  54. }
  55. header a.search span:last-of-type {
  56. /* background-color: orangered; */
  57. background-color: linear-gradient(to left, orangered, #ffc000);
  58. color: white;
  59. padding: 0.06rem 0.15rem;
  60. border-radius: 0.3rem;
  61. margin-right: 0.05rem;
  62. }
  63. header a.iconfont {
  64. color: #ff5000;
  65. font-size: large;
  66. }

reset.css

  1. * {
  2. margin: 0;
  3. padding: 0;
  4. box-sizing: border-box;
  5. }
  6. /* 链接 */
  7. a {
  8. text-decoration: none;
  9. color: #555;
  10. }
  11. li {
  12. list-style: none;
  13. }
  14. /* 移动端1rem */
  15. html {
  16. font-size: calc(100vw / 3.75);
  17. }
  18. /* 因为font-size:100px太大,需要在body中重置 */
  19. body {
  20. font-size: 0.13rem;
  21. color: #333;
  22. background-color: #f4f4f4;
  23. margin: auto;
  24. padding: 0 0.15rem;
  25. }
  26. body img {
  27. width: 100%;
  28. }
  29. @media (max-width: 320px) {
  30. html {
  31. font-size: 85px;
  32. }
  33. }
  34. @media (min-width: 640px) {
  35. html {
  36. font-size: 170px;
  37. }
  38. }

效果图展示

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