Blogger Information
Blog 7
fans 0
comment 0
visits 3945
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
简单的3行3列布局和固定定位
冷风
Original
684 people have browsed it

简单的3行3列布局和固定定位

效果图

  • 代码如下:

    1.主要用到三个属性 position: absolute;position: relative;position: fixed;

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>Document</title>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. box-sizing: border-box;
  13. }
  14. :root {
  15. font-size: 10px;
  16. }
  17. header,
  18. footer {
  19. height: 5rem;
  20. background: #522332;
  21. }
  22. .container {
  23. min-height: 40rem;
  24. position: relative;
  25. margin: 0.5rem 0;
  26. }
  27. .container aside {
  28. width: 15rem;
  29. background: #5646;
  30. min-height: inherit;
  31. position: absolute;
  32. }
  33. .container aside:first-of-type {
  34. left: 0;
  35. top: 0;
  36. }
  37. .container aside:last-of-type {
  38. right: 0;
  39. top: 0;
  40. }
  41. body {
  42. position: relative;
  43. }
  44. .container main {
  45. min-height: inherit;
  46. background: burlywood;
  47. position: absolute;
  48. left: 15.5rem;
  49. right: 15.5rem;
  50. }
  51. .container main img {
  52. position: fixed;
  53. left: 20rem;
  54. top: 10rem;
  55. }
  56. </style>
  57. </head>
  58. <body>
  59. <header>页眉</header>
  60. <div class="container">
  61. <aside>左侧</aside>
  62. <main>
  63. <img src="111.png" alt="" />
  64. </main>
  65. <aside>右侧</aside>
  66. </div>
  67. <footer>底部</footer>
  68. </body>
  69. </html>
Correcting teacher:天蓬老师天蓬老师

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!