在CSS中使用多个伪元素可以吗? [英] Is it ok to use multiple pseudo-elements in css?

查看:776
本文介绍了在CSS中使用多个伪元素可以吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个菜单,其中每个项目都以·分隔。为此,我使用

I want to make a menu where each item is separated with a ·. To achieve this I use

menu li:before {
    content: "· ";
}

这很不错,但它也会在第一个项目之前产生一个点。因此,我也想使用:first-child 伪类。我可以这样做吗?

This is swell, but it generates a dot before the first item as well. Therefore, i would like to use :first-child pseudo-class as well. Can I do this?

推荐答案

当然可以- http://jsfiddle.net/WQBxk/

p:before {
    content: "BEFORE ";
    display: block;
}

p:first-child:before {
    content: "1ST";
    display: block
}
​

不好-它在IE7及以下版本中将无法使用。不是因为有多个伪选择器,而是因为不受支持的:before - http://kimblim.dk/css-tests/selectors/

The bad - it won't work in IE7 and below. Not because of the multiple pseudo selectors, but because of non-supported :before - http://kimblim.dk/css-tests/selectors/

刚刚在IE8中测试过-效果很好。

Just tested in IE8 - works well.

这篇关于在CSS中使用多个伪元素可以吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆