css常用的属性

CSS------属性值篇

display: none | block | inline(默认值) | inline-block(css2新增) | inherit

       none :此元素不会再显示 {注:虽然visibility也是隐藏,但是他隐藏之后在页面上还是占位的,而display:none在页面上是不占位的}

       block:块元素,独占一行

       inline:行内元素,没有宽高,内容的多少就是他的宽高,也会是display的默认值

       inline-block:行内块元素,可以把一个元素转换成行内块元素,同时具有block和inline的特性

       inherit:继承,继承父元素的

display还有其他的

display:table | inline-table | table-header-group | table-row-group | table-footer-group | table-row| table-column-group | table-column | table-cell | table-caption

    table:块级表格来显示(类似 <table>

    inline-table:内联表格来显示(类似 <table>

    table-header-group:一个或多个行的分组来显示(类似 <thead>

    table-row-group:一个或多个行的分组来显示(类似 <tbody>

    table-footer-group:一个或多个行的分组来显示(类似 <tfoot>

    table-row:一个表格行显示(类似 <tr>

    table-column-group:一个或多个列的分组来显示(类似 <colgroup>

    table-column:一个单元格列显示(类似 <col>

    table-cell:一个表格单元格显示(类似 <td><th>

    table-caption:一个表格标题显示(类似 <caption>

margin (外边距): 上 右 下 左(值可以为像素,也可以为百分比)

  margin-left:元素距离左边的距离

     margin-right:元素距离右边的距离

       margin-top:元素距离上边的距离

       margin-bottom:元素距离下边的距离

   注:让一个元素居中的方法

   #margin{margin:0 auto;}

position: static | relative | absolute | fixed |inherit

      static:静态

        relative:相对定位

          相对定位的元素仍在文档流之中,并按照文档流中的顺序进行排列;

          参照物为元素本身的位置;

          "left:20" 会向元素的 LEFT 位置添加 20 像素;

          常用的用途为改变元素层级和设置为绝对定位的参照物;

        absolute:绝对定位

          建立以包含块为基准的定位,其随即拥有偏移属性和 z-index 属性;

          默认宽度为内容宽度;

          脱离文档流;

          参照物为第一个定位祖先或根元素(<html>元素);

          元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定。

       fixed:固定定位

          默认宽度为内容宽度

          脱离文档流

          参照物为视窗

          元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定.

    tip:任何元素都可以定位,一个元素加上绝对或固定定位后就自动转变为块级元素

    

原文地址:https://www.cnblogs.com/white-bull/p/7729641.html