CSS a:当前功能
我想使用 a:current 属性来更改样式 元素 .但问题是a href不能 指向另一个页面。 所以我创造了这样的东西。
<a class='linkstyl' href="#1" >A</a>
<a class='linkstyl' href="#2" >B</a>
<a class='linkstyl' href="#3" >C</a>
我的css文件是这样的
.linkstyl{
cursor:hand;cursor:pointer;text-decoration:none;
color: #ccc;
}
.linkstyl:current{
cursor:hand;cursor:pointer;text-decoration:none;
color: #aaa;
}
但是当前的功能没有像想象的那样工作,如何纠正它?
I want to use the a:current attribute to change the style of
the element . But the problem is that the a href cannot be
made to point to another page .
So I created something like this .
<a class='linkstyl' href="#1" >A</a>
<a class='linkstyl' href="#2" >B</a>
<a class='linkstyl' href="#3" >C</a>
My css file is something like this
.linkstyl{
cursor:hand;cursor:pointer;text-decoration:none;
color: #ccc;
}
.linkstyl:current{
cursor:hand;cursor:pointer;text-decoration:none;
color: #aaa;
}
But the current feature doesn't work as thought , how to rectify it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非这是全新的,否则没有 CSS psuedo 选择器
:current
。您可能会想到:active
或:focus
。但是,一旦元素失去焦点,例如单击页面上的其他任何位置,
:focus
将不会应用。:active
仅在元素“激活”时应用,通常意味着单击鼠标或类似操作时。这是一个包含两者的演示,您可以看看这是否是您想要的: http://jsfiddle.net/HW8X6/
旁注:
id
或name
属性不应以数字开头,您可能需要将它们从 1、2 和 3 更改类似的东西item-1
、item-2
、item-3
。Unless this is brand new, there is no CSS psuedo selector
:current
. You may be thinking of:active
or:focus
.:focus
will not be applied however, once the element loses focus, for example if you click anywhere else on the page.:active
is only applied when the element is "activated", usually that just means while the mouse is being clicked or similar.Here's a demo with both so you can see if this is what you want: http://jsfiddle.net/HW8X6/
Side note:
id
orname
attributes should not start with a number, you may want to change them from 1, 2, and 3 to something likeitem-1
,item-2
,item-3
.您完全错过了这个“时间线性表示”伪类的要点。
尝试再次阅读选择器级别 4 规范的当前草案。
您想使用
.linkstyl:current
选择什么?您知道最近的浏览器都不支持它,对吧?
a:local-link
可能就是您的真的想要。You are completely missing the point of this "time-linear presentation" pseudo-class.
Try to read the current draft of the Selectors Level 4 specification again.
What are you trying to select with
.linkstyl:current
?You know that no recent browsers support it, right?
a:local-link
is probably what you really wanted.