我有一個小問題試圖讓下面的工作,並不知道是否是CSS3設計處理或不處理。我環顧四周,發現支持多個背景圖片,但嘗試很多例子導致了nada。創建一個帶背景和前景圖像的按鈕
這是主CSS代碼用於呈現我的按鈕:
.button {
background:#eee url(images/button.gif) repeat-x 0 0;
border:solid 1px #b1a874;
color:#7f7f7f;
font-size:11px;
padding:2px 6px 2px 6px;
cursor:pointer;
line-height:14px !important;
}
以上代碼生成標準按鈕其是精細。但是現在我想在某些按鈕上添加圖標,例如打印按鈕。我用2臺額外的CSS類:
input.addImage {
background-repeat: no-repeat; /* once */
background-position: 5px 2px;
padding-left: 16px;
vertical-align: middle;
}
和:
input.Print {
background-image: url(../img/buttons/print.png); /* 16px x 16px */
}
正如你可以看到我的形象是其中能裝進按鈕事實16×16。然而,原始背景圖像被完全剝離,使背景顏色透明。
我相信,如果可能的話,其基本的東西我可以忽略,並期待着解決這個問題。
最後按鈕的代碼:
<input type="button" class="button addImage Print" ... >
感謝您的寶貴時間。
不幸的是,這段代碼也使button的button.gif背景只重複一次。我確實嘗試過這樣:( – Tarquin
然後你需要用同樣的方式使用longhand形式:'background:#eee url(images/button.gif)repeat-x,url(../ img/buttons/print。png)no-repeat 5px 2px' – cimmanon
當你說慢速手術時,我試過了,它沒有工作,所以我把它合併成一個類,它工作。這不是我想要去的方式,但你是對的。 – Tarquin