What does “pseudo” mean in CSS? [duplicate]

帅比萌擦擦* 提交于 2019-12-22 07:51:53

问题


When I read about CSS and HTML I cross the word pseudo-elements.

I haven't found a good short explanation for what pseudo means. Could someone please explain this to me?


回答1:


Supposed or purporting to be but not really so; false; not genuine:

— https://en.oxforddictionaries.com/definition/pseudo-

A pseudo-element is something that acts like an element, but is not an element.




回答2:


psuedo-elements allow you to style specific parts of an element. Some examples of pseudo-elements are:

  • ::after
  • ::before

These specific ones allow you to add style to just after, or just before an element.

for example:

.test {
    background-color: gray;
}

.test::after {
    content: ' some more text';
    color: red
}
<div class='test'>
    testing...
</div>

Here, we style the .test element normally

BUT, then we add a bit more after it using the pseudo-element selector ::after to let us add more text and change the colour.

You can read more and see more examples at https://developer.mozilla.org/en/docs/Web/CSS/Pseudo-elements




回答3:


In a word, "fake".

A more complete definition can be found here: http://www.dictionary.com/browse/pseudo




回答4:


A pseudo element is a CSS-generated non-DOM element that is rendered as if it was a DOM element in the browser. But it doesn't actually add a node to the DOM. So if you inspected it in, say Chrome Dev Tools, you won't see it as a regular node.

Interestingly some screen-readers read pseudo-element content and others don't.



来源:https://stackoverflow.com/questions/41272227/what-does-pseudo-mean-in-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!