2013-07-05 23 views
1

所以我有一個框我需要顯示一些文本,有一個紅色的背景顏色,也有一個圖像在框的右側。css有一個背景顏色,文本和圖像在同一個div

這個想法是,文本應該優先,背景顏色應該仍然是紅色。

下面是一個例子,但它覆蓋的背景色:

.test { 
    background-color: #e64e56;; 
    box-shadow: 3px 3px 5px darkGray; 
    color: white; 
    background: url(http://thumb10.shutterstock.com/thumb_small/536008/103572833/stock-photo-small-flower-isolated-on-white-background-103572833.jpg) no-repeat top right; 

} 

http://jsbin.com/axohoc/1/edit

回答

3

你的意思呢?

.test { 
    box-shadow: 3px 3px 5px darkGray; 
    color: white; 
    background: #e64e56 url(http://thumb10.shutterstock.com/thumb_small/536008/103572833/stock-photo-small-flower-isolated-on-white-background-103572833.jpg) no-repeat top right; 
} 

您可以定義background-colorbackground-imagebackground-repeatbackground-position分開,或者使用快捷background。使用後者時,它會覆蓋您設置的具體規則,在這種情況下background-color

這裏是例子,編輯http://jsbin.com/axohoc/7/edit

在這裏,您可以在速記屬性的細節讀了,還有不同的具體背景屬性:http://www.w3schools.com/css/css_background.asp

+1

偉大的芒,你給了很多細節 – GuiGreg