博客列表 >html之常用布局实例

html之常用布局实例

小庄
小庄原创
2021年07月04日 12:33:17823浏览

html之常用布局实例

  1. 1. 制作一个在线QQ客服的固定定位(QQ客服用图片就行)
  2. 2. 仿课堂案例写一个三行三列的定位布局, 色块或边框代表内容就可以;
  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. <link rel="stylesheet" href="./font_icon_qq/iconfont.css">
  9. </head>
  10. <style>
  11. *{
  12. /* 初始化 */
  13. margin: 0px;
  14. padding: 0;
  15. box-sizing: border-box;
  16. }
  17. header, footer{
  18. height: 5rem;
  19. background-color: lightblue;
  20. }
  21. .container{
  22. width: 80%;
  23. position: relative;
  24. margin: 0.5em auto;
  25. min-height: calc(100vh - 11rem);
  26. }
  27. .container aside{
  28. position: absolute;
  29. width: 200px;
  30. min-height: inherit;
  31. background-color: magenta;
  32. }
  33. /* 左 */
  34. .container aside:first-of-type{
  35. left: 0;
  36. top: 0;
  37. }
  38. /* 中 */
  39. .container main{
  40. position: absolute;
  41. min-height: inherit;
  42. left: 205px;
  43. right: 205px;
  44. background-color: mediumaquamarine;
  45. }
  46. /* 右 */
  47. .container aside:last-of-type{
  48. right: 0;
  49. top: 0;
  50. }
  51. .qq{
  52. position:fixed;
  53. z-index: 999;
  54. left: 2rem;
  55. top: 40rem;
  56. }
  57. </style>
  58. <body>
  59. <header>页眉</header>
  60. <div class="container">
  61. <aside></aside>
  62. <main></main>
  63. <aside></aside>
  64. </div>
  65. <div class="qq">
  66. <div><span class="iconfont icon-qq"></span></div>
  67. <div><span class="iconfont icon-external_qq"></span></div>
  68. </div>
  69. <footer>页脚</footer>
  70. </body>
  71. </html>
上一条:0628作业下一条:CSS-作业
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议