What is the default display property of the :before and :after pseudo-elements?

问题内容:

What is the default display: properties of :AFTER and :BEFORE pseudoelements after you specify content.

Is it display: inline or display: inline-block?

Could not find it in default css values list

Example:

div {
  border: solid 1px black;
  padding: 5px;
  }

div:before {
  content: "Before: Am I inline-block or inline?";
  color:red;
 }

div:after {
  content: "After: Am I Inline-block or inline?";
  color:green;
 }
<div>Div 1</div>
<div>Div 2</div>
<div>Div 3</div>
<div>Div 4</div>

问题评论:

1  
..oh and they aren’t pseudo-classes they are pseudo-ELEMENTS
    
okay thanks for the correction
– Kagerjay
44 mins ago

答案:

答案1:

The :before and :after pseudo-elements are inline by default.

As the W3 spec says:

In a :before or :after pseudo-element declaration, non-inherited
properties take their initial values.

And the initial value of the display property is inline.

答案评论:

原文地址:

https://stackoverflow.com/questions/47755989/what-is-the-default-display-property-of-the-before-and-after-pseudo-elements

Tags:,

添加评论