Sunday, 15 September 2013

css - Alignment of html pseudo-element after -


How can I align my pseudo-element to the center? Like margin: 0 auto; For block elements.

  & lt; Div & gt; This is test text. This is test text. This is test text & lt; / Div & gt;  

CSS code:

  div: after {position: absolute; Display area; material:""; Border color: # EAB920 Transparent transparent transparent; Border-style: solid; Threshold Width: 2.5 AM; Width: 0; Height: 0; }  

This element looks like a simple triangle Margin of property: 0 auto; not working.

If you want the pseudo-element to be centered horizontally centered relative text, You set the target element to display in inline-block so that the width becomes smaller to fit the content, then remove the full position from the pseudo-element and the margin : Auto will work as expected.

  & lt; Div class = "target" & gt; This test text is test text, it's test text. & Lt; / Div & gt; If you do not want to centrally orient the pseudo-element in horizontal form, then change the element to  inline-block < / Code> - 

not set

No comments:

Post a Comment