css網(wǎng)站建設總結
css是一種表現(xiàn)html文件樣式的計算機語言 ? ? ?css可以控制html標簽中的屬性、文字、圖片樣式
三種樣式
基本規(guī)則:內(nèi)嵌大于內(nèi)部大于外部



語法
如div{font-size:18px; ? ? ?font-size 屬性 ? ? ?18px 屬性值 ? ? div ?選擇器
代碼
基礎
width寬 ? height高 ? line-height行高 ? ? z-index 層疊順序
字體
color字體顏色 ? font-size字體大小 ? font-family字體名稱
背景
background-image背景圖片 ? ? background-size背景大小 ? ?background-color背景顏色
位置
text-align: left | right | center水平對齊 ? ? text-align:center居中 ? position:fixed固定定位
邊距
left左邊距 ? top上邊距 ? right右邊距 ? bottom下邊距
邊框(border復合屬性 ?在后面加很多屬性值)
border-color邊框顏色 ? border-style邊框樣式 ? dashed虛線 solid實線 ? border-width邊框的寬度
border-left左邊框 ? border-right右邊框 ? border-top上邊框 ? border-bottom下邊框
外邊距
margin-top外上邊距
margin : 0 auto 當元素定義為width屬性時,auto可以有居中的效果;0 在前意思是上下邊距0px,auto左右邊距為自動
margin-right外右邊距
margin-bottom外下邊距
margin-left外左邊距
margin外邊距的復合使用
內(nèi)邊距 padding關于內(nèi)邊距的復合屬性
padding-top 上內(nèi)邊距
padding-right右內(nèi)邊距
padding-bottom下內(nèi)邊距
padding-left左內(nèi)邊距
padding:10px;所有邊框都是10px
浮動
fioat ?浮動方式 left right ? ? clear both(清除左右浮動) ? ? 頁面中有兩個div,后面的div會被自動放在第二行,因為每個div會占據(jù)一整行,如果想在一行顯示兩個div如何設置?
display 顯示方式 ? ? ? 取值:block塊級顯示 ? inline行內(nèi)顯示 ? none不顯示不占定位空間 ? ? ? ? ? ? ? ? ? ? ? ?不能加寬高的標簽是內(nèi)聯(lián)元素;反之能加寬高的標簽是塊級元素