博客列表 >固定定位以及三行三列的定位布局

固定定位以及三行三列的定位布局

wan-PHP
wan-PHP原创
2021年07月05日 14:57:48507浏览

1.在线QQ客服的固定定位

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=qq, initial-scale=1.0" />
  7. <title>qq</title>
  8. <style>
  9. .box {
  10. height: 15vh;
  11. width: 40vw;
  12. background-color: skyblue;
  13. position: absolute;
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <div class="box">
  19. <img src="q.png" alt="qq" width="190" height="60" />
  20. </div>
  21. </body>
  22. </html>
  23. `

2.三行三列的定位布局

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=`, initial-scale=1.0" />
  7. <title>三行三列</title>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. box-sizing: border-box;
  13. }
  14. html {
  15. font-size: 10px;
  16. }
  17. body {
  18. font-size: 1.6rem;
  19. }
  20. header,
  21. footer {
  22. height: 6rem;
  23. background-color: royalblue;
  24. text-align: center;
  25. }
  26. .container {
  27. margin: 0.1rem 0;
  28. background-color: olivedrab;
  29. min-height: calc(100vh - 12.2rem);
  30. position: relative;
  31. text-align: center;
  32. }
  33. .container aside {
  34. width: 20rem;
  35. min-height: inherit;
  36. position: absolute;
  37. background-color: orange;
  38. }
  39. .container aside:first-of-type {
  40. left: 0;
  41. top: 0;
  42. background-color: red;
  43. }
  44. .container aside:last-of-type {
  45. right: 0;
  46. top: 0;
  47. }
  48. .container main {
  49. position: absolute;
  50. left: 20.5rem;
  51. right: 20.5rem;
  52. min-height: inherit;
  53. }
  54. </style>
  55. </head>
  56. <body>
  57. <header>页眉</header>
  58. <div class="container">
  59. <aside>左侧</aside>
  60. <main>内容区</main>
  61. <aside>右侧</aside>
  62. </div>
  63. <footer>页脚</footer>
  64. </body>
  65. </html>

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