WordPress 菜单中不接受 First-Child 伪类
我有一个页脚导航,其中使用了从以下位置调用的分隔符:
#footnav li:before {
content:'\00B7';
}
我无法定位第一个子元素,以便点不会显示在第一个元素之前。我正在尝试:
#footnav li:first-child {
content:'';
}
我还尝试调用与 WordPress 中的菜单项相关联的类。由于它是 wordpress,我无法进入并为第一个目标 li 添加实际的 span 标签。 wordpress有什么技巧吗?
这是网站(主题、页脚导航):
I have a footer navigation where I'm using dividers called from:
#footnav li:before {
content:'\00B7';
}
I can't target the first child so that the dots do not show before the first element. I'm trying:
#footnav li:first-child {
content:'';
}
And I've also tried calling the class that is tied to the menu item in wordpress. Since it's wordpress I can't go in and put an actual span tag for the first targeted li. Is there a trick with wordpress?
This is the site (topic, footer nav):
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
一路上,将您的
#footnav a
类设置为显示为内联块,以正确修复对齐方式。Try this:
Along the way, set your
#footnav a
class to display as inline-block to fix the alignment properly.css content: 属性并不打算按照您尝试的方式使用(用于替换文本)。为此,您需要使用 javascript。内容只能在伪元素(例如:before)上使用来插入文本,而不能使用伪选择器(例如:first-child)来替换文本。
您可能想要使用 content 属性的一个很好的例子是,如果您想在链接后插入箭头:
有关详细信息,您可以阅读以下内容: http://css-tricks.com/6555-css-content/
The css content: property is not intended to be used the way you're trying to (for replacing text). For that you'd need to use javascript instead. Content can only be used on pseudo-elements (e.g. :before) to insert text, not with pseudo-selectors (e.g. :first-child) to replace text.
A good example of where you might want to use the content property is if you want to insert an arrow after a link:
For more info you could read this: http://css-tricks.com/6555-css-content/