我是初学者,所以如果你知道其他解决方案,请告诉我 ;) 我想让我网站上的菜单看起来像这样:
link / link / link / link / link
菜单在里面,所以这是我做的:
li:before {
content: "/";
}
li:first-of-type {
color: #FFF; /* I've made first "/" same color as background, so we don't see it */
}
有一些填充标签,所以看起来不错,但我想让它更容易阅读。
在大多数浏览器中它看起来不错,但当然旧的 Internet Explorer 不支持 :first-of-type 标签。我怎样才能解决这个问题,让用户不会只看到第一个斜杠?
最佳答案
li:first-child:before {
content: '';
}
IE7及更高版本支持:first-child
伪类。
请注意,IE7 支持 :first-child
( with some caveats ),但直到 IE9 才支持它的 friend :last-child
。
此外,要隐藏使用 content
属性添加的内容,请不要更改颜色以匹配背景颜色,因为这就是我所说的丑陋的 hack。
相反,将其content
设置为空字符串,如上例所示。
关于css - IE 和 :first-of-type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5648142/