Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css] 第121天 请举例说明伪元素 (pseudo-elements) 有哪些用途? #1066

Open
haizhilin2013 opened this issue Aug 14, 2019 · 4 comments
Labels
css css

Comments

@haizhilin2013
Copy link
Collaborator

第121天 请举例说明伪元素 (pseudo-elements) 有哪些用途?

@haizhilin2013 haizhilin2013 added the css css label Aug 14, 2019
@xiangshuo1992
Copy link
Contributor

  1. 作为实际DOM元素使用
  2. 作为一些视觉装饰性的元素使用

@LinStan
Copy link

LinStan commented Aug 15, 2019

可以用于给元素添加伪元素来调整布局。
可以添加伪元素,通过content添加内容

@forever-z-133
Copy link

  1. 可以不用再多写一个 dom
  2. 可以用 content 搭配出很多效果

例子:

  1. 固定尺寸 2:1 的容器
  2. 文本前后增加 icon 或图片
  3. 使用 data-* 和 content: attr(data-*) 搭配
  4. 使用 :hover 和 content 搭配出很多效果
  5. 作为修饰元素
  6. 使用 content: counter() 玩有序数字
  7. 参与 inline-block 垂直居中

@nowherebutup
Copy link

我经常用于装饰性的元素,不用再多写一个其他元素

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css css
Projects
None yet
Development

No branches or pull requests

5 participants