【发布时间】:2015-01-09 14:53:00
【问题描述】:
我的网站内有正常的链接状态和悬停状态,但由于某种原因活动状态不起作用,为什么这不起作用。有人可以帮忙吗。我希望在活动状态下,该链接不会变回原来的颜色。
ul#menu li a {
text-decoration: none;
font-family:'Novecento Sans W01 Lt';
font-size:14px;
color:white;
background-color: #223e99 ;
border-left:solid;
border-left-color: #223e99 ;
border-right:solid;
border-right-color: #223e99 ;
border-left-width:32px;
border-right-width:32px;
border-top:solid;
border-top-color:#223e99 ;
border-top-width:15px;
border-bottom:solid;
border-bottom-color:#223e99 ;
border-bottom-width:15px;
margin-left:-18px;
}
ul#menu li a:hover {
text-decoration: none;
font-family:'Novecento Sans W01 Lt';
font-size:14px;
color:white;
background-color: #7fc14b ;
border-left:solid;
border-left-color: #7fc14b ;
border-right:solid;
border-right-color: #7fc14b ;
border-left-width:32px;
border-right-width:32px;
border-top:solid;
border-top-color:#7fc14b ;
border-top-width:15px;
border-bottom:solid;
border-bottom-color:#7fc14b ;
border-bottom-width:15px;
margin-left:-18px;
}
ul#menu li a:active{
text-decoration: none;
font-family:'Novecento Sans W01 Lt';
font-size:14px;
color:white;
background-color: #7fc14b ;
border-left:solid;
border-left-color: #7fc14b ;
border-right:solid;
border-right-color: #7fc14b ;
border-left-width:32px;
border-right-width:32px;
border-top:solid;
border-top-color:#7fc14b ;
border-top-width:15px;
border-bottom:solid;
border-bottom-color:#7fc14b ;
border-bottom-width:15px;
margin-left:-18px;
}
【问题讨论】:
-
不是
:visited而不是: active被点击的链接的伪类吗? -
是的@Huey,活动是当鼠标(或手指)点击并在按钮(或手指)释放后立即被移除。但我认为张贴者想要的只是在你在那个页面上时给它一个颜色。
-
在这种情况下,单靠 CSS 是行不通的。您需要将
:active代码放在一个单独的类中,该类添加后端或通过 js。 -
我该怎么做?
-
@Martin 下面有一些答案,现在大约六周了。他们中的任何一个有帮助吗?如果是这样,请考虑接受对您最有帮助的那个。