<asp:IE8+ 中的按钮文本抖动



按钮内的文本抖动或向下移动几个像素。

<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?)

我在这里错过了什么?

不确定您的 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>

我认为这应该对你有用。

最新更新