按钮内的文字猛然或移动减去几个像素。
<div>
<asp:Button runat="server" ID="Button1" CssClass="ButtonClass" Text="" runat="server" />
</div>
ascx.cs:
Button1.Text = LocalizationResourceManager.GetLocalizedValue("Button_Text");
CSS:
.ButtonClass{
background: url('/Button.png') no-repeat scroll 0 0 transparent;
cursor: pointer;
font-weight: bold;
font-size: 14px;
height: 33px;
padding-bottom: 7px;
padding-right: 19px;
width: 180px;
border: solid 0px;
color: #fff!important;
background-position: 0px -31px;
}
如果有<span>
,我可以使用:
{position:relative;top;0;left:0;}
由于span
无法在asp:button
内使用,因此我希望修复此按钮本身。
我试过了:
<asp:LinkButton ID="Button1" runat="server" CssClass="ButtonClass">
<span runat="server" id="ButtonText"></span>
</asp:LinkButton>
ascx.cs:
ButtonText.text = LocalizationResourceManager.GetLocalizedValue("Button_Text");
我有错误:
Error 9 'System.Web.UI.HtmlControls.HtmlGenericControl' does not contain a definition for 'text' and no extension method 'text' accepting a first argument of type 'System.Web.UI.HtmlControls.HtmlGenericControl' could be found (are you missing a using directive or an assembly reference?)
我在这里缺少什么?
答案 0 :(得分:0)
不确定CSS是否实际应用于按钮但是如果您想在按钮内使用span,为什么不将控件更改为链接按钮,如下所示:
<asp:LinkButton ID="Button1" runat="server" CssClass="Button1">
<span>Register 2</span>
</asp:LinkButton>
编辑:
<asp:LinkButton ID="Button1" runat="server" CssClass="Button1">
<span>
<asp:Label ID="ButtonText" runat="server" ></asp:Label>
</span>
</asp:LinkButton>
我认为这应该适合你。