国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > CSS > 正文

CSS的background屬性的縮寫順序介紹

2024-07-11 08:31:20
字體:
來源:轉載
供稿:網友
background 屬性是background-color,background-image,background-position,background-attachment,background-repeat,這五個屬性的縮寫,優點是比單個屬性書寫要簡單,要少寫很多代碼。就是有時令人在書寫這五個屬性的順序上有些困擾。下面一段代碼取自搜狐:

復制代碼
代碼如下:
.bBot{background:url(../images20130624/bg.png) no-repeat -1424px -5px;overflow:hidden;height:1px;clear:both;font-size:0px; overflow:hidden;}
.cBot{background:url(../images20130624/sohubg01.png) 0 -181px repeat-x;width:758px;height:6px;clear:both;font-size:1px;margin:0 auto;}

.bBot 選擇器的background屬性的順序是background-image,background-repeat,backgroundf-position。(background-repeat在前,backgroundf-position在后)

.cBot 選擇器的background屬性的順序是background-image,background-position,background-repeat。(background-position在前,background-repeat在后)

就是同一個公司的CSS的風格書寫都不一樣的,覺得有點不應該。

那就讓我們看看CSS的background屬性的官方定義:

Value: ['background-color'> ||<'background-image'> || <'background-repeat'>|| <'background-attachment'> ||<'background-position'>] | inherit
Initial: see individual properties
Applies to: all elements
Inherited: no
Percentages: allowed on 'background-position'
Media: visual
Computed value: see individual properties

上面表格的內容只是定義的background屬性的值包含那些內容,但并沒有指定這些值的順序(不過可以認為這是建議順序,如果都這樣做,代碼可讀性更好)。

總結:

background屬性的值的書寫順序官方并沒有強制標準的。
為了可讀性,定一個CSS書寫規范,規則2.1:background的值的順序是background-color,background-image,background-repeat,background-attachment,background-position。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 静乐县| 西昌市| 多伦县| 新营市| 泰兴市| 淮北市| 锡林浩特市| 延川县| 会宁县| 仙游县| 文登市| 同心县| 涪陵区| 丹寨县| 利辛县| 彰化县| 南昌县| 肃北| 盈江县| 淳安县| 南漳县| 迭部县| 桃园市| 乌拉特前旗| 沽源县| 德州市| 龙口市| 贺州市| 武宣县| 东安县| 樟树市| 东明县| 长沙市| 义马市| 铅山县| 綦江县| 玛曲县| 廊坊市| 浙江省| 鄂尔多斯市| 桂平市|