I have a little problem with the “active” state in CSS. I have a <ul> in which there are 4 lists and I want to give these links a different background-color (and stay that way!) if they are clicked. The problem is that this won’t work…
This is my HTML:
<nav id="quick-index-nav">
<ul id="quick-index-list" class="pills slim muted">
<li class="active">
<a id="qindex-popular" title="..." target="right" href="right.php">everything</a>
</li>
<li>
<a id="qindex-today" title="..." target="right" href="right.php?t=tod">today</a>
</li>
<li class="yesterday">
<a id="qindex-yesterday" title="..." target="right" href="right.php?t=yes">tomorrow</a>
</li>
<li>
<a id="qindex-day" title="...." target="right" href="right.php?t=mix">never</a>
</li>
</ul>
</nav>
and this is my CSS file:
#quick-index-nav{margin-bottom:10px; margin-left: -50px;}
#quick-index-list{margin-bottom:0;*zoom:1;border:0px ridge #d9d9d9}
#quick-index-list:before,#quick-index-list:after{display:table;content:""}
#quick-index-list:after{clear:both}
#quick-index-list li{display:inline-block;float:left;width:25%;margin:0;border:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;border-right:0px ridge #d9d9d9}
#quick-index-list li:nth-child(4n){border-right:0px}
#quick-index-list li:nth-child(n+5){border-top:0px ridge #d9d9d9}
#quick-index-list li>a{padding:0;display:block;font-size:1.0em;text-align:center; font-family: Calibri;}
.pills>li{display:inline-block;margin-bottom:5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;border:1px solid #d9d9d9}
.pills>li>a{padding:6px 10px;cursor:pointer;display:inline-block}
.pills>li>a:hover{text-decoration:none}
.pills>li:hover{background-color:#d9d9d9;text-decoration:none}
.pills>li.active{background-color:#456695;border-color:#456695}
.pills>li.active>a{color:#fff}
.pills.slim>li>a{padding:3px 5px;font-size:.9em}
.pills.muted>li>a{color:gray}
.pills.muted>li.active>a{color:#fff};
.muted {
color: gray;
}
What is wrong with it?
PS: here is a demo http://jsfiddle.net/1BJK903/fxTQL/5/
As I understand, you want to use active pseudo class, than you should have
pills>li:active>a. Also, I know like it is applied to links only (never used it and this may be wrong), so possibly you will need to change you class like this:pills>li>a:activeUpdate
After some tests appeared that this
pills>li:active>aworks in FF, Chrome and IE8+ and does not work in IE7To do what you need you can enable jquery on your page with this code. Second script tag contains code which will change classes.