CSS 最佳實踐 + 套路(一) -- 概述
資源
- Google: 關鍵詞 MDN
- CSS Tricks
- Google: 阮一峯 css
- 張鑫旭的 240 多篇 CSS 博客
- Codrops 炫酷 CSS 效果
- CSS揭祕
- CSS 2.1 中文 spec
- Magic of CSS 免費在線書
引入CSS
- 內聯樣式 ==> style屬性 ==>
style= 'color: red; width: 200px; height:200px;'
-
內嵌樣式 ==>
style
標籤 ==>1
2
3
4
5
6<style>
body{
background: gray;
font-size: 12px;
}
</style> -
外聯樣式 ==>
<link>
標籤 ==>1
<link rel= 'stylesheet' href= ''>
-
@import url(./b/css)
最佳實踐 & 套路
reset CSS
1
2
*{ margin: 0; padding: 0; }
h1, h2, h3, h4, h5, h6, p{ margin: 0; padding: 0; }
清除浮動
添加到浮動元素的父元素上。
1 |
.clearfix::after{ |
相關知識點
元素分類:
- 塊級元素:
block
==>display: block;
- 內聯元素:
inline
==>display: inline;
- 內聯塊級元素:
inline-block
==>display: inline-block;