zoukankan      html  css  js  c++  java
  • css之盒模型

    盒模型

    1.定义

    1.任意一个元素都可以当作盒模型
    2.盒子的大小由内容宽高(width/height)+边距(padding)+边框(border)
    3.盒子由外边距(margin),影响盒子的位置
    广义盒模型:文档中所有功能性及内容性标签,及文档中所有显示性标签.
    狭义盒模型:文档中以块级形式存在的标签(块级标签拥有盒模型100%特性且最常用)
    

    2.盒模型成员介绍

    content
    • 通过设置width与height来规定content
    • 块级标签可以设置自身宽高,默认宽为父级宽(width=auto),高为自动(由内容撑开)
    • 内联标签不可以设置自身宽高,默认均为自动(由内容撑开)
    border
    • border(边框)由border-width(宽度)、border-color(颜色)、border-style(风格)三部分组成

    • border成员:border-left、border-right、border-top、border-bottom

    • border-width成员:border-left-width、border-right-width、border-top-width、border-bottom-width

    • border-color成员:border-left-color、border-right-color、border-top-color、border-bottom-color

    • border-style成员:border-left-style、border-right-style、border-top-style、border-bottom-style

    风格 解释
    solid 实线
    dashed 虚线
    dotted 点状线
    double 双实线
    groove 槽状线
    ridge 脊线
    inset 内嵌效果线
    outset 外凸效果线
    margin
    • margin成员:margin-left、margin-right、margin-top、margin-bottom
    • margin整体设置
    赋值个数 方位
    1 上下左右
    2 上下|左右
    3 上|左右|下
    4 上|右|下|左
    • 总结:1.规定起始位置 2.顺时针 3.不是找对面

    3.边界圆角

    border-radius
    • border-radius成员
    成员 解释
    border-top-left-radius 左上 方位
    border-top-right-radius 右上 方位
    border-bottom-left-radius 左下 方位
    border-bottom-right-radius 右下 方位
    • 单方位设置
    赋值个数(值类型:长度或百分比):1  解释为:横纵
    赋值个数(值类型:长度或百分比):2  解释为:横|纵
    
    • 分向整体设置
    格式:1/1  解释为:横向|纵向
    

    4.其他相关属性

    • max|min-width|height
    • overflow
    visible 默认值。内容不会被修剪,会呈现在元素框之外。
    hidden 内容会被修剪,并且其余内容是不可见的。
    scroll 内容会被修剪,但是浏览器会显示滚动条以便查看其余的内容。
    auto 如果内容被修剪,则浏览器会显示滚动条以便查看其余的内容。
    inherit 规定应该从父元素继承 overflow 属性的值。
    • display
    描述
    inline 内联
    block 块级
    inline-block 内联块

    5.盒模型布局

    盒模型布局基本介绍
    • 布局方位:margin-left、margin-right、margin-top、margin-bottom
    • 影响自身布局:margin-left、margin-top
    • 影响兄弟布局:margin-right、margin-bottom
    • 正向 / 反向:正值 / 负值
    margin布局坑
    • 很多语义标签具有默认margin
    • 父子标签margin-top重叠取大者
    • 兄弟标签margin-bottom、margin-top重叠取大者
  • 相关阅读:
    uitableview中文排序问题
    跳转到指定页面popToViewController用法
    [__NSCFConstantString size]: unrecognized selector sent to instance 错误
    [NSThread sleepForTimeInterval:3.0];
    XCode 4.3 Unable to load persistent store UserDictionary.sqlite 以及 ios simulator failed to install the application
    ios 6.0模拟器页面调出pop窗口消失后无法使用键盘
    iOS真机测试,为Provisioning添加设备
    [IOS笔记]
    UITableView 滚动时使用reloaddata出现 crash'-[__NSCFArray objectAtIndex:]: index (1) beyond bounds (0)' Crash
    C# 自定义用户控件
  • 原文地址:https://www.cnblogs.com/louyefeng/p/9703039.html
Copyright © 2011-2022 走看看