本篇文章適合css新手學(xué)習(xí),對于已經(jīng)掌握了css的朋友們也可以通過本片文章來復(fù)習(xí)知識。
作者通過實(shí)踐,認(rèn)為在有些情況下css的代碼是可以更加簡潔的,多數(shù)情況下是因?yàn)樾率謱τ谝恍┚哂卸鄬傩缘脑卮a不能精簡來寫造成的。
精簡的代碼對于網(wǎng)頁是有莫大的好處的,對于瀏覽者訪問速度會有一定的提升,另外對于搜索引擎也更加可以抓取網(wǎng)頁關(guān)鍵內(nèi)容。廢話不說了,下面就看看筆者總結(jié)的可以精簡的代碼:
以下為引用的內(nèi)容: 1.Margin & Padding 例1: .div { margin-top:10px; margin-right: 5px; margin-bottom:30px; margin-left:0px; } |
精簡后代碼如下:
以下為引用的內(nèi)容: .div { margin:10px 5px 30px 0;}) 例2: .div { margin-top:10ox; margin-right:20px; margin-bottom:0; margin-left:20px; } |
精簡后代碼:
以下為引用的內(nèi)容: .div { margin:10px 20px 0; } 例3: .div { margin-top:0; margin-right:auto; margin-bottom:0; margin-left:auto; } |
精簡后代碼:
以下為引用的內(nèi)容: .div { margin:0 auto; } 例4: .div { margin-top:50px; margin-right:50px; margin-bottom:50px; margin-left:50px; } |
上一篇 ajax實(shí)例教程:模擬google動態(tài)提示效果
下一篇 Access數(shù)據(jù)庫提示OleDbException (0x80004005): 操作必須使用一個(gè)可