【问题标题】:ASP.net Button with CssClass not working带有 CssClass 的 ASP.net 按钮不起作用
【发布时间】:2015-08-28 02:57:14
【问题描述】:

问题:

我有两个 ASP.net Buttons 在 Chrome 和 Firefox 浏览器中可以正常工作,但在 IE 9.0 中却不行。

*Does not work on IE 9.0*
<asp:Button ID="btnMeal" runat="server" onclick="btnMeal_Click" Text="." CssClass="buttonmeal" />

*Works fine on IE 9.0 and other browsers*
<asp:Button ID="btnType" runat="server" onclick="btnType_Click" Text="." CssClass="button"/>

CSS 代码:

/*Doesnt work*/
.buttonmeal
 {
        background: url('../images/meal.png') no-repeat;
        width:82px;
        height:32px;
        border:0px;     
    }

/*Works*/
    .button
    {
        background: url('../images/type.png') no-repeat;
        width:82px;
        height:32px;
        border:0px;     
    }

也许我认为问题在于它在 IE 中的呈现方式不同,并且在 IE 中只使用了按钮。

<td class="myStyle">
    <input type="button" name="select" ...>
</td>

【问题讨论】:

  • 您是否在 IE 中进行过硬刷新以确保它获得正确的 CSS?您还可以使用 IE 开发人员工具 (F12) 检查元素以了解发生了什么。
  • 您的按钮之间的唯一区别是在btnMeal 之前带有空格`/>` 的结束标签和在btnType 之前没有空格的结束标签/&gt;
  • IE 中的硬刷新修复了它。谢谢各位。

标签: asp.net css


【解决方案1】:

很可能是缓存问题(反正对我来说)。您的浏览器没有使用最新版本的 CSS 文件,这是一个很好的变化。尝试重新刷新:

Chrome / IE / FirefoxCtrl + R

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-24
    • 1970-01-01
    • 2014-12-29
    • 2011-04-28
    • 1970-01-01
    • 1970-01-01
    • 2019-04-23
    • 1970-01-01
    相关资源
    最近更新 更多