css 樣式

高度和寬度

塊級標籤才能夠設置寬度和高度
內聯標籤的寬度是由內容的長度決定
1. height
2. width
  1. 字體相關
    1. font-size
    2. font-family
    3. font-weight
  2. 文本相關
    1. color
      1. 直接顏色名
      2. 十六進制 --> #00FF00
      3. rgb格式 --> rgb(0,255,0)
    2. 對齊方式
      1. text-align:center --> 居中
    3. 文本裝飾
      text-decoration
      none --> 去掉a標籤默認的下劃線
      under-line
      over-line
      line-through
    4. 首行縮進
      text-indent
  3. 背景
    background: url('xx.png' no-repeat center center)
  4. 邊框
    border: 1px solid red
  5. display
    1. none
    2. inline
    3. block
    4. inline-block
      display:inline-block引起的間隙問題解決辦法(4px)?
      緣由:換行或空格會佔據必定的位置,從而產生間隙
      在父元素設置font-size:0
      display: none和visibility: hidden的區別?
      都是隱藏頁面上的標籤
      display: none隱藏標籤而且不佔位置
      visibility: hidden 隱藏標籤的同時會佔住位置
  6. 盒子模型
    內容>內填充(padding)>邊框(border)>外邊距(margin)
  7. 浮動
    1. 浮動多用於頁面大範圍佈局
    2. 浮動
      • left 往左浮動
      • right 往右浮動
    3. 清除浮動的反作用
      1. clear
        • left 左邊不能有浮動元素
        • right 右邊不能有浮動元素
        • both 兩邊都不能有浮動元素
      2. 經常使用class
        .clearfix:after {
        content: '';
        display: block;
        clear:both
        }
  8. 溢出
    overflow
    - hidden
    - scroll
    - auto
  9. 定位
    1. 相對定位:相對 標籤原來的位置 作的定位
      position: relative
      left:
      top:
      bottom:
      right:
    2. 絕對定位:相對 已經定位過的祖先標籤 作的定位
      多用於頁面局部的佈局,注意要和定位過的祖先標籤配合使用
      絕對定位和浮動同樣,標籤都會脫離文檔,別的標籤能夠佔用它的位置
    3. 固定定位
      固定定位相對於 屏幕 固定顯示在某個位置
      固定定位的元素也是脫離文檔的
  10. z-index屬性設置元素的堆疊順序。擁有更高堆疊順序的元素老是會處於堆疊順序較低的元素的前面。Z-index 僅能在定位元素上奏效(例如 position:absolute;)!
相關文章
相關標籤/搜索