简单区分`:before`与`::before`的区别

简单区分:before::before的区别


:hover我们都知道,称作伪类,英文名pseudo-class,而我们此处提到的:before以及:after也是伪类,属于css2的内容,在ie8下也能正常的支持


至于::before,引用MDN的解释

::before creates a pseudo-element that is the first child of the element matched. It is often used to add cosmetic content to an element by using the content property. This element is inline by default.

也就是说,::before是伪元素pseudo-element而不是伪类

The ::before notation (with two colons) was introduced in CSS3 in order to establish a discrimination between pseudo-classes and pseudo-elements. Browsers also accept the notation :before introduced in CSS 2.

::before是属于css3的内容,之所以引入该属性,是为了与:before区分开,::before在ie8下不支持,其余的浏览器均支持该属性

外国友人以及国内大牛都很喜欢使用这两个属性,毕竟可以省写一个标签,同时为了兼容性考虑的话,尽量使用css2的:before

转载于:https://www.cnblogs.com/jelly7723/p/5602349.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值