0

我有以下标记,我们在 iphone 4 上运行它,所以像 Hover 这样的一些 CSS 元素不起作用。

<asp:Repeater ID="rpt" runat="server">
    <HeaderTemplate>
        <div class="table withshadow">
    </HeaderTemplate>
    <ItemTemplate>
         <a href='<%#Eval("HistoryTeacherURL")%>' class="tablerow list navigate">
            <div class="tablecell listitem left">
                <asp:Label ID="lblDesc" Text='<%#Eval("Name")%>' runat="server" CssClass="item" /><br />                    
            </div>                            
            <div class="tablecell listitem right">
                <touch:TutorialSheets ID="lblBal" Text='<%#Eval("Tutorial")%>' runat="server" CssClass="amount item" />
            </div>
            <div  class="tablecell listitem witharrow">                        
            </div>
         </a>
    </ItemTemplate>
    <FooterTemplate>
        </div>
    </FooterTemplate>
</asp:Repeater>

我们想要的是,当我们点击链接时,颜色应该变为红色!问题是这种类型的 CSS 可以在 Firefox 上运行,但不能在 iphone 4 上运行。

a:active
{    
    background-color: #31ac48;
    font-color: #ffffff;
}

看到这个问题的替代解决方案(javascript、jquery 等)也很棒,这样至少其中一个可以在 iphone 4 上运行 :-)

4

2 回答 2

1

您可以使用 jQuery。

$("a").click(function() {
    if $(this).is(":active") {
        (this).css("font-color", "red");
    }
});

见小提琴:http: //jsfiddle.net/bMyMd/

于 2013-03-12T03:42:17.147 回答
1

你是使用所有的伪类还是只使用一个?
如果您至少使用两个,请确保它们的顺序正确,否则它们都会中断:

a:link
a:visited
a:hover
a:active

以该顺序。此外,如果您只是使用:active,请添加a:link,即使您没有对其进行样式设置。

于 2013-03-12T04:32:23.593 回答