2013-03-11 75 views
-1

嘿,我的問題很簡單,我試圖做一個按鈕,就像你可以在VB中獲得的形式。例如,我想在我的按鈕中輸入一些文字,我也想在其中放置一張圖片。唯一的問題是,在VB.net中只有兩種類型的按鈕,第一種是帶有圖像的按鈕,根本沒有文本,第二種是隻有文本的按鈕。我發現的唯一方法是將圖像放在背景中。不幸的是,圖像正在按下按鈕中的所有空間。我想知道是否有對齊回地面圖像向左或向右例如如何使用VB.net中的文本創建圖像按鈕?

這裏我對按鈕的HTML代碼的方式:

<asp:Button ID="btn_LoadReport" runat="server" Text="Charger" 
    style="margin-left: 0px; margin-bottom: 0px; margin-right:0px;"             
          Height="35px" Width="102px" 
          CssClass="Charger" /> 

這是CSS代碼我對當下:

.Charger 
{ 
    background-image:url(report.png); 
    background-repeat:no-repeat; 
    text-align:left;  
} 

THX

+1

[你有什麼試過?](http://whathaveyoutried.com) – Shauna 2013-03-11 14:31:24

回答

1

我試過把圖像與CSS背景,但我的文字是在日e圖片

這就是background-position attribute的用途。

<button>Text</button> 

button { 
    padding-right:40px; 
    background-image:url(myImage.png); 
    background-repeat:no-repeat; 
    background-position:center right; 
} 

請注意,padding-right屬性用於防止文本與圖像重疊。

JSFiddle example

相關問題