0
点赞
收藏
分享

微信扫一扫

C语言复习概要(一)

何晓杰Dev 2024-10-08 阅读 35
css前端

9、CSS盒子模型

9.1 CSS常用长度单位
<style>
    html {
        font-size: 50px;
    }

    /* px(像素单位) */
    #div1 {
        height: 200px;
        width: 200px;
        font-size: 20px;
        background-color: aqua;
    }

    /* em(相对于当前元素font-size的倍数),若没有font-size,则在祖先元素中寻找,祖先元素中都不存在则采用浏览器默认值 */
    #div2 {
        height: 10em;
        width: 10em;
        font-size: 20px;
        background-color: yellow;
    }

    /* rem(相对于根元素html的font-size)的倍数 */
    #div3 {
        height: 4rem;
        width: 4rem;
        font-size: 20px;
        background-color: blue;
    }


    #div4 {
        height: 200px;
        width: 200px;
        font-size: 20px;
        background-color: gray;
    }

    /* 相对其父元素的百分比 */
    .div5 {
        width: 50%;
        height: 20%;
        font-size: 150%;
        background-color: red;
    }
</style>
9.2 元素的显示模式
  • 块元素

9.3 修改元素的显示模式
<style>
    div {
        height: 400px;
        width: 400px;
        font-size: 40px;
        display: inline-block;
    }
</style>

10、盒子模型的组成部分

模型

  • margin不影响盒子大小,只影响盒子位置。
<style>
    div {
        /* 内容区的宽 */
        width: 400px;
        /* 内容区的高 */
        height: 400px;
        /* 内边距,背景颜色填充到内边距区域 */
        padding: 10px;
        /* 边框,背景颜色填充到边框区域 */
        border: 20px dashed burlywood;
        /* 外边距 */
        margin: 50px;
        font-size: 20px;
        background-color: gray;
    }
</style>
10.1 内容区
CSS属性功能属性值
width设置内容区域的宽度长度
min-width设置内容区域的最小宽度长度
max-width设置内容区域的最大宽度长度
height设置内容区域的高度长度
min-height设置内容区域的最小高度长度
max-height设置内容区域的最大高度长度
  • width一般不与min-width、max-width使用
  • height一般不与min-height、max-height使用

持续更新中!!!

相关代码地址:https://gitee.com/justinc666/front-end/tree/master/CSS/CSS盒子模型

举报

相关推荐

0 条评论