什么:: before和:: after是什么意思? [英] What do ::before and ::after mean?

查看:579
本文介绍了什么:: before和:: after是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在看一对Twitter的Bootstrap模板,我看到很多 :: 和 ::之后插入 div 标记之前和之后。

I was looking at a couple Twitter Bootstrap templates and I saw that a lot of ::before and ::after were inserted before and after div tags.

任何人都可以告诉我他们是什么?

Can anybody tell me what they are?

推荐答案

伪元素,你不直接包括在你的标记,但可以使用CSS创建一些整洁的效果。你已经提到了 :: before :: after 之后,它们代表伪元素,

They represent pseudo-elements, which you don't include directly in your markup, but are available to you to create some neat effects with CSS. You have mentioned ::before and ::after, and they represent pseudo-elements that appear, shockingly, before and after your elements.

整个列表包含在下面,应该是非常清楚的:

The whole list is included below and should be fairly self-explanatory:

::after 
::before 
::first-letter 
::first-line 
::selection

ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements

注意使用双冒号,这与规范一致。有时你会看到用单个冒号指定的伪元素,但这只是因为我们需要支持不理解双冒号语法的浏览器。

Note the use of the double-colon, which is consistent with the spec. Sometimes you will see pseudo-elements specified with a single colon, but that was only because we needed to support browsers that didn't understand the double-colon syntax.

这篇关于什么:: before和:: after是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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