width and height doesn't seem to work on :before pseudo-element

后端 未结 5 1564
小鲜肉
小鲜肉 2020-12-08 00:20

Here is a fiddle.

foo bar baz

and

a.infolink::before
{
         


        
5条回答
  •  执念已碎
    2020-12-08 00:40

    Note: The ::before and ::after pseudo-elements are actually laid display: inline; by default.

    Change the display value to inline-block for the width & height to take effect while maintaining inline formatting context.

    a.infolink::before {
        content: '?';
        display: inline-block;
        background: blue;
        color: white;
        width: 20px;
        height: 20px;
    }
    

    http://jsfiddle.net/C7rSa/3/

提交回复
热议问题