2013-01-16 124 views
1

我有一個菜單欄,我想兩個圖像附加到它 這是我did-添加多背景圖片在CSS

background:url('images/bgs/bg_container_top_left.png') no-repeat top left ,url('images/bgs/bg_container_top_center.png') no-repeat top right; 

我如何可以分配不同的屬性附在這裏不同的圖像? 一樣,如果我想給保證金的第一圖像

margin-left:-10px; 

和第二圖像

margin-left:-5px; 
+0

代替邊距,您可以嘗試以下背景位置:0 0 0 -10px,0 0 0 -5px;可能會有所幫助。 –

回答

2

,如果你想定位不是改變圖像論文propertites

例如:

background:url('images/bgs/bg_container_top_left.png') no-repeat top -10px ,url('images/bgs/bg_container_top_center.png') no-repeat top -5px; 

或使用background-position: 0px 0px 0px 10px;

0

嘗試此

div{background: url('http://blog.agilebits.com/wp-content/uploads/2012/05/time-machine-icon.png') -5px top no-repeat, url('http://aux3.iconpedia.net/uploads/69290979.png') -10px top no-repeat ; } 

DEMO

0

CSS3允許使用多個背景圖像。使用的格式是您在第一部分中顯示的內容。

​​

而不是使用保證金,我有一個懷疑可能無法正常工作(你可以自己動手,如果你想測試一下),我會建議使用的背景位置屬性(https://developer.mozilla.org/en/docs/CSS/background-position)調整爲每一個首發位置背景。如果每個元素的實際邊距不同,則可能需要考慮爲每個背景創建單獨的元素。你可以嘗試使用此代碼:

margin-left: -10px, -5px; 

這同樣遵循格式(上市背景屬性值1第一,和值2秒),但我不知道這是支持的。