• CSS 笔记三(Tables/Box Model/Outline)


    CSS Tables

    border

    border: border-width border-style border-color|initial|inherit;

    border-width

    border- medium|thin|thick|length|initial|inherit;

    border-style

    border-style:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|initial|inherit;

    Table Borders

    Example

    1 table, th, td {
    2    border: 1px solid black;
    3 }

    border-collapse

    • Specify whether the table borders are collapsed into a single border or detached as in standard HTML.
    border-collapse: separate|collapse|initial|inherit;

    border-spacing

    • Specify the distance between the borders of adjacent cells (only for the "separated borders" model).
    border-spacing: length|initial|inherit;

    Example

    1 table {
    2     border-collapse: separate;
    3     border-spacing: 10px 50px;
    4 } 

    Horizontal Alignment

    text-align: left|right|center;

    Vertical Alignment

    vertical-align: top|bottom|middle;

    Caption-side

    • Specify the placement of a table caption.
    caption-side: top|bottom|initial|inherit;

    Table-layout

    • Specify the table layout algorithm to be used for a table.
    table-layout: auto|fixed|initial|inherit;
    ValueDescription
    auto Automatic table layout algorithm (this is default):
    • The column width is set by the widest unbreakable content in the cells
    • Can be slow, since it needs to read through all the content in the table, before determining the final layout
    fixed Fixed table layout algorithm:
    • The horizontal layout only depends on the table's width and the width of the columns, not the contents of the cells
    • Allows a browser to lay out the table faster than the automatic table layout
    • The browser can begin to display the table once the first row has been received

    Empty-cells

    • Specify whether or not to display borders and background on empty cells in a table (only for the "separated borders" model).
    empty-cells: show|hide|initial|inherit;

    Table Padding

    • Control the space between the border and the content in a table

    Example

    th, td {
        padding: 15px;
        text-align: left;
    }

     

    • Use the :hover selector on <tr> to highlight table rows on mouse over
    tr:hover {background-color: #f5f5f5}

    Striped Tables

    • Use the nth-child() selector and add a background-color to all even (or odd) table rows

    tr:nth-child(even) {background-color: #f2f2f2}

    Responsive Table

    • display a horizontal scroll bar if the screen is too small to display the full content

     Example

    1 <div style="overflow-x:auto;">
    2 
    3 <table>
    4 ... table content ...
    5 </table>
    6 
    7 </div> 

    CSS Box ModelCSS box-model

    Explanation of the different parts:

    • Content - The content of the box, where text and images appear
    • Padding - Clears an area around the content. The padding is transparent
    • Border - A border that goes around the padding and content
    • Margin - Clears an area outside the border. The margin is transparent

    Width and Height of an Element

    Important:

      When you set the width and height properties of an element with CSS, you just set the width and height of the content area. To calculate the full size of an element, you must also add padding, borders and margins.

    Example

    1 div {
    2     width: 320px;
    3     padding: 10px;
    4     border: 5px solid gray;
    5     margin: 0;
    6 }

    Total element width = width + left padding + right padding + left border + right border + left margin + right margin

    CSS Outline

    • An outline is a line drawn around an element - outside the border.
    • The outline is NOT a part of an element's dimensions.
    • the element's total width and height is not affected by the width of the outline.

    Outline

    outline-style values

    • dotted - Defines a dotted outline
    • dashed - Defines a dashed outline
    • solid - Defines a solid outline
    • double - Defines a double outline
    • groove - Defines a 3D grooved outline. The effect depends on the outline-color value
    • ridge - Defines a 3D ridged outline. The effect depends on the outline-color value
    • inset - Defines a 3D inset outline. The effect depends on the outline-color value
    • outset - Defines a 3D outset outline. The effect depends on the outline-color value
    • none - Defines no outline
    • hidden - Defines a hidden outline

    Example

     1 p {
     2     border: 1px solid black;
     3     outline-color: red;
     4 }
     5 
     6 p.dotted {outline-style: dotted;}
     7 p.dashed {outline-style: dashed;}
     8 p.solid {outline-style: solid;}
     9 p.double {outline-style: double;}
    10 p.groove {outline-style: groove;}
    11 p.ridge {outline-style: ridge;}
    12 p.inset {outline-style: inset;}
    13 p.outset {outline-style: outset;}

    Result

    A dotted outline.

    A dashed outline.

    A solid outline.

    A double outline.

    A groove outline. The effect depends on the outline-color value.

    A ridge outline. The effect depends on the outline-color value.

    An inset outline. The effect depends on the outline-color value.

    An outset outline. The effect depends on the outline-color value.

    Outline - Shorthand property

    • same to border

    Example

    1 p {
    2     border: 1px solid black;
    3     outline: 5px dotted red;
    4 }
    • Specify the space between an outline and the edge or border of an element
    outline-offset: length|initial|inherit;

    Example:

    div {
        border: 2px solid black;
        outline: 2px solid red;
        outline-offset: 15px;
    } 
  • 相关阅读:
    Python re 模块中,如何使用反斜杠 ""分割字符串?
    VisualVM使用:Local Applications Cannot Be Detected
    九、Delphi10.3通过Json.Serializers实现反序列号,将JSON转换成数组
    vue项目 通过配置webpack插件DllPlugin进行打包速度优化,以及本地运行编译速度优化
    企业微信小程序 导购快捷联系用户 wx.qy.openUserProfile 的使用示例
    微信 支付即服务 服务人员注册 和 AEAD_AES_256_GCM 的使用 (sodium_crypto_aead_aes256gcm_decrypt 或者 sodium_crypto_aead_aes256gcm_is_available() )无法使用 的解决方案
    git仓库服务搭建
    配置中心 ------- Nacos
    Feign的介绍和使用
    Ribbon + Nacos 自定义负载均衡算法
  • 原文地址:https://www.cnblogs.com/hzj680539/p/5081308.html
Copyright © 2020-2023  润新知