CSS佈局-筆記

  1. Cascading Style sheets,層疊樣式表;
  2. style屬性,是內聯樣式,就是寫在標籤裏的樣式;
  3. 外部樣式,用link標籤的方式引入stylesheet
  4. <link rel="stylesheet" href="./a.css">
  5. 總結
  • 內聯style屬性;
  • style標籤;
  • 外部文件css link
  • @import url(./b.css);

6. 佈局問題,必定要背

給全部的子元素加上float:left;
給子元素的爸爸添加上名爲clearfix的類;css

.clearfix::after{
    content: '';
    display: block;
    clear: both;
}
複製代碼
  1. 頁面默認字體大小是16px
  2. 文字裝飾爲空,取消下劃線
    text-decoration: none
  3. 使la包裹住a,
    display: block
  4. 跟隨爸爸的顏色;有些元素能夠繼承,有些不能夠,color能夠;
    color: inherit;
  5. padding順序是上右下左;
    padding: 20px 16px 20px 16px;
  6. 塊級元素div高度由其內部文檔流元素的高度總和決定;
  7. 內聯元素高度跟字體及字體設計師設置的參數有關;
  8. 文檔流:文檔內元素的流動方向;內聯元素從左往右流動,遇到寬度不夠換行繼續流動;塊級元素每一個塊佔一行,一次從上往下;
  9. border調試大法:border:1px solid red;
  10. 內聯元素很長時默認不會打斷,添加word-break:break-all;能夠將其打斷;
  11. display:inline-block;儘可能不用這個,用float;
  12. 字體基線對齊;
  13. 字體有建議行高;
  14. 深刻了解,搜索「方應杭 CSS line height」;
  15. height儘可能不要寫,會有bug;
  16. position: fixed;脫離文檔流;相對於屏幕;少用width:100%;
  17. max-width: 940px;最大寬度能夠自適應;
  18. margin-left: auto; margin-right: auto;即可自動居中;
  19. span裏不能放地div,會出bug;span里加display:block就是div;
  20. position: absolute;相對於祖先中的第一個position: relative;定位;
  21. 搜索css tricks shape,圖畫參考;
  22. iconfont工具網站;
  23. 讓簡歷裏圖標svg上下空出的空間相等;
  24. display:inline;須要後續學習;
  25. content-box與border-box區別
  26. 太極圖畫法:
.yin-yang {
    
    width: 192px;
    box-sizing: content-box;
    height: 96px;
    background: #eee;
    border-color: red;
    border-style: solid;
    border-width: 4px 4px 100px 4px;
    border-radius: 100%;
    position: relative;
  }
  .yin-yang:before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    background: #eee;
    border: 36px solid red;
    border-radius: 100%;
    width: 24px;
    height: 24px;
    box-sizing: content-box;
  }
  .yin-yang:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    background: red;
    border: 36px solid #eee;
    border-radius: 100%;
    width: 24px;
    height: 24px;
    box-sizing: content-box;
  }
複製代碼

效果圖:
bash

相關文章
相關標籤/搜索