[英]how to make a label go bold when a mouse go over it and back to normal afterwards
[英]How to make label text underline when i move mouse over it, and then make the label text normal on mouse leave
當我將鼠標移到標簽文本上時,我試圖使標簽文本帶有下划線。 我用下面的代碼。
private void Q1lbl_MouseMove(object sender, MouseEventArgs e)
{
var font = Q1lbl.Font;
Q1lbl.Font = new Font(font, FontStyle.Underline);
}
private void Q1lbl_MouseLeave(object sender, EventArgs e)
{
font.Dispose()
}
這必須在客戶端而不是服務器端完成。 您可能需要使用懸浮選擇器將css類添加到標簽
http://www.w3schools.com/cssref/sel_hover.asp
您可以設置text-decoration: underline;
在課堂里。
這是一個小玩意兒,以展示它的實際效果。
.underlineHover:hover{
text-decoration: underline;
}
在標記中,您要添加具有cssClass屬性名稱的css類
<asp:label id="mylabel" runat="server" text="hover text" cssClass="underlineHover" />
你能用CSS做到這一點嗎? 如果是這樣,則my_element:hover {text-decoration:underline;}
請嘗試使用以下代碼段。
CSS
.link:hover{
text-decoration:underline;
}
ASPX
<asp:Label CssClass="link"></asp:Label>
Label
控件的內容用<span>
標簽包圍(除非您使用AssociatedControlID
屬性,否則Label
控件將呈現<label>
標簽)。
因此,您可以簡單地為標簽創建樣式,並將其應用於您的標簽。
span:hover {text-decoration: underline;}
如果您要使用特定的范圍ID,則可以在樣式中提及范圍ID
#myspanId:hover {text-decoration: underline;}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.