博主信息
博文 52
粉丝 0
评论 3
访问量 54185
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
html学习:第8章 框模型与定位
王小飞
原创
810人浏览过

实列演示代码:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>Document</title>
  7. <style>
  8. body {
  9. height: 2000px;
  10. /* 网站整体传个背景图 */
  11. background-image: url(images/t018b071039ea200dc7.jpg);
  12. background-repeat: no-repeat;
  13. }
  14. /* 设置一个框,margin设置margin:auto使它在页面居中 */
  15. .nei {
  16. width: 1200px;
  17. height: 800px;
  18. margin: auto;
  19. border: 5px solid;
  20. }
  21. .nei1 {
  22. width: 200px;
  23. height: 200px;
  24. background-color: rgb(15, 226, 86);
  25. border: 1px solid;
  26. margin-top: 20px;
  27. padding-top: 10px;
  28. float: right;
  29. /* 相对定位,配合top,left,right,bottom使用 */
  30. position: absolute;
  31. top: 200px;
  32. /* 因为box的margin被浏览器强制为boody的宽度,所有定位700px没有靠着右边 */
  33. left: 700px;
  34. }
  35. .nei2 {
  36. width: 300px;
  37. height: 300px;
  38. border: 1px solid;
  39. background-color: rgb(14, 124, 235);
  40. float: right;
  41. }
  42. .xuan {
  43. width: 150px;
  44. height: 200px;
  45. background-color: rgb(201, 58, 22);
  46. position: fixed;
  47. right: 0;
  48. bottom: 0;
  49. }
  50. </style>
  51. </head>
  52. <body>
  53. <!-- 第一个大框 -->
  54. <div class="nei"">
  55. <!-- 第一个小框 -->
  56. <div class="nei1"></div>
  57. <!-- 第二个小框 -->
  58. <div class="nei2"></div>
  59. </div>
  60. <!-- 悬浮 -->
  61. <div class="xuan"></div>
  62. </body>
  63. </html>

效果:

批改老师:天蓬老师天蓬老师

批改状态:不合格

老师批语:看一下作业要求, 不能这样写
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系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+教程免费学