溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

CSS中的background屬性怎么使用

發(fā)布時(shí)間:2022-04-22 14:07:28 來源:億速云 閱讀:125 作者:iii 欄目:大數(shù)據(jù)

這篇文章主要講解了“CSS中的background屬性怎么使用”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“CSS中的background屬性怎么使用”吧!

background 屬性是background-color,background-image,background-position,background-attachment,background-repeat,這五個(gè)屬性的縮寫,優(yōu)點(diǎn)是比單個(gè)屬性書寫要簡(jiǎn)單,要少寫很多代碼。就是有時(shí)令人在書寫這五個(gè)屬性的順序上有些困擾。下面一段代碼取自搜狐:

代碼如下:

.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在后)
就是同一個(gè)公司的CSS的風(fēng)格書寫都不一樣的,覺得有點(diǎn)不應(yīng)該。
那就讓我們看看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
上面表格的內(nèi)容只是定義的background屬性的值包含那些內(nèi)容,但并沒有指定這些值的順序(不過可以認(rèn)為這是建議順序,如果都這樣做,代碼可讀性更好)。

感謝各位的閱讀,以上就是“CSS中的background屬性怎么使用”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)CSS中的background屬性怎么使用這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI