【问题标题】:css not applying for asp.net hyperlinkcss不申请asp.net超链接
【发布时间】:2014-04-06 15:04:33
【问题描述】:

在我的asp.net 应用程序中,有一个hyperlink。当我使用css 将鼠标悬停在它上面时,我想将它的color 更改为白色,但它不起作用。

<asp:HyperLink ID="hlViewItem" class="hplClass" runat="server"  NavigateUrl='<%#Eval("Pro_Id","ProductDetails.aspx?ProID={0}") %>' ForeColor="#33ccff">View Item</asp:HyperLink>

我的css

.hplClass:hover
{
    color:white;
}

【问题讨论】:

标签: html asp.net css hyperlink hover


【解决方案1】:

对于 ASP.NET 控件,使用属性 CssClass 而不是“类”。

【讨论】:

  • 现在我已经编辑了我的代码,但仍然无法工作 查看项目
  • 渲染的 HTML 是否包含class="hplClass"
  • 是的。查看源代码后,我得到了这个 查看项目
  • 那你应该看看别处。也许你的 CSS 没有被加载。如果您将 &lt;style&gt;.hplClass:hover { color: white; }&lt;/style&gt; 放在您的控件之前,那应该确保 CSS 存在。如果可行,请查看为什么 CSS 没有从您之前的位置加载。
【解决方案2】:

试试这个(去掉 ForeColor="#33ccff" 之后):

<asp:HyperLink ID="hlViewItem" CssClass="hplClass" runat="server"  NavigateUrl='<%#Eval("Pro_Id","ProductDetails.aspx?ProID={0}") %>'>View Item</asp:HyperLink>

还要确保您已在您的 aspx 页面中添加了 css 文件的引用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-17
    • 2012-06-03
    • 2010-09-17
    相关资源
    最近更新 更多