博主信息
博文 5
粉丝 0
评论 0
访问量 3009
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
0702固定定位
AlUN
原创
591人浏览过

0702作业

制作一个在线QQ客服的固定定位

  1. <style>
  2. * {
  3. padding: 0;
  4. margin: 0;
  5. box-sizing: border-box;
  6. }
  7. .image {
  8. width: 5em;
  9. }
  10. .kefu {
  11. position: relative;
  12. height: 900em;
  13. }
  14. .image {
  15. position:fixed;
  16. top: 20em;
  17. bottom: 0;
  18. right: 0;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <div class="kefu">
  24. <img src="https://img0.baidu.com/it/u=3464795985,1960072882&fm=26&fmt=auto" alt="" class="image">
  25. </div>
  26. </body>

三行三列的定位布局

  1. <style>
  2. * {
  3. padding: 0;
  4. margin: 0;
  5. box-sizing: border-box;
  6. }
  7. body *:not(.container) {
  8. background-color: lightgreen;
  9. }
  10. :root {
  11. /* rem布局 */
  12. font-size: 10px;
  13. }
  14. body {
  15. font-size: 1.6rem;
  16. }
  17. header ,
  18. footer {
  19. height: 5rem;
  20. /* background-color: lightblue; */
  21. }
  22. .container {
  23. margin: 0.5rem 0;
  24. min-height: calc(100vh - 11rem);
  25. position: relative;
  26. }
  27. .container aside {
  28. width: 20rem;
  29. min-height: inherit;
  30. position: absolute;
  31. }
  32. .container aside:first-of-type {
  33. left: 0;
  34. top: 0;
  35. }
  36. .container aside:last-of-type {
  37. right: 0;
  38. top: 0;
  39. }
  40. .container main{
  41. position:absolute;
  42. left: 20.5rem;
  43. right: 20.5rem;
  44. /* background-color: lightgreen; */
  45. min-height: inherit;
  46. }
  47. </style>
  48. </head>
  49. <body>
  50. <header>页眉</header>
  51. <div class="container">
  52. <aside>左侧</aside>
  53. <main>内容区</main>
  54. <aside>右侧</aside>
  55. </div>
  56. <footer>页脚</footer>
  57. </body>
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学