2013-04-28 40 views
2

我想讓圖像出現在div的左側(垂直居中)。這是如何完成的?如何將圖像添加到div的左側

這是我的代碼。 (圖像在每個角落都顯得非常小,我已經嘗試了後臺網址(../ images/error24x24.png)不重複;但是這也不能正確工作(圖像加載,但看起來很時髦)

.formValidation { 
    background-color:rgb(71,89,32); 
    color:white; 
    font-weight:bold; 
    padding:10px; 
    -moz-border-radius:6px; 
    border-radius:6px; 
    -webkit-border-image: url(../images/error24x24.png); 
    border-image: url(../images/error24x24.png); 
} 

    <div class="formValidation"> 
     Please enter a category. 
    </div> 

編輯:我的最後CSS:

.formValidation { 
    background-color:rgb(52,31,36); 
    color:white; 
    font-weight:bold; 
    padding:10px 10px 10px 35px; 
    -moz-border-radius:15px; 
    border-radius:15px; 
    margin-bottom:10px; 
    background-image: url(../images/error24x24.png); 
    background-position:8px center; 
    background-repeat:no-repeat; 
} 

回答