码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 元素的层级与绝对定位布局


    目录

    一、效果展示

    二、元素层级

    1、效果

    2、特点

    3、修改

    三、绝对定位布局

    1、水平垂直布局公式(在绝对定位下必须满足)

    2、要求

    四、代码

    1、元素层级

    2、绝对定位布局


    一、效果展示

      

    二、元素层级

    1、效果

    层级高的元素会覆盖层级低的元素

    2、特点

    (1)父元素层级永远不会超过子元素大小

    (2)同层级优先显示标签靠后的元素

    3、修改

    (1)通过z-index修改层级优先级大小

    (2)z-size需要数字参数,愈大层级越高

    三、绝对定位布局

    1、水平垂直布局公式(在绝对定位下必须满足)

    (1)水平

    left + margin-left\right + padding-left\right + content + right = width

    (2)垂直

    top + margin-top\bottom + padding-top\bottom + bottom = height

    2、要求

    (1)left、right、top、bottom具有最高优先级

    (2)在过度约束条件下,若不对此四个值限定,则默认为auto,优先修改此四类值

    四、代码

    1、元素层级

    1. 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>元素的层级title>
    8. <style>
    9. .box1{
    10. width: 200px;
    11. height: 200px;
    12. background-color: #bfa;
    13. position: relative;
    14. z-index: 1;
    15. }
    16. .box2{
    17. width: 200px;
    18. height: 200px;
    19. background-color: red;
    20. position: absolute;
    21. left: 50px;
    22. top: 50px;
    23. z-index: 2;
    24. }
    25. .box3{
    26. width: 200px;
    27. height: 200px;
    28. background-color: yellow;
    29. position: absolute;
    30. left: 100px;
    31. top: 100px;
    32. z-index: 3;
    33. }
    34. .box4{
    35. width: 100px;
    36. height: 100px;
    37. background-color: blue;
    38. position: absolute;
    39. }
    40. style>
    41. head>
    42. <body>
    43. <div class="box1">div>
    44. <div class="box2">div>
    45. <div class="box3">
    46. <div class="box4">div>
    47. div>
    48. body>
    49. html>

    2、绝对定位布局

    1. 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>绝对定位布局title>
    8. <style>
    9. .box1 {
    10. background-color: #bfa;
    11. width: 400px;
    12. height: 400px;
    13. position: relative;
    14. }
    15. .box2 {
    16. background-color: red;
    17. width: 50px;
    18. height: 50px;
    19. margin: auto;
    20. position: absolute;
    21. left: 0px;
    22. right: 0px;
    23. top: 0px;
    24. bottom: 0px;
    25. }
    26. style>
    27. head>
    28. <body>
    29. <div class="box1">
    30. <div class="box2">div>
    31. div>
    32. body>
    33. html>

  • 相关阅读:
    不知道如何将文字转语音?不如跟着我一起来操作
    对话ChatGPT:AIGC时代下,分布式存储的应用与前景
    顺利通过论文查重检测的小技巧
    ThingsBoard教程(五二):规则节点解析 AWS SNS Node, AWS SQS Node
    基于Bagging集成学习方法的情绪分类预测模型研究(文末送书)
    刷爆力扣之至少是其它数字两倍的最大数
    msyql锁分类
    旅游门户/旅行社网站-pc+移动端+可小程序+app强大功能-适合运营周边游/国内游/出境游
    Python的基础语法
    基于SSM的学生宿舍管理系统
  • 原文地址:https://blog.csdn.net/comegoing_xin_lv/article/details/126166846
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号