CSS ::before ::after pseudo-element of class not working

后端 未结 1 1268
臣服心动
臣服心动 2021-02-19 12:09

I am trying to add a ::before and ::after pseudo-element to a menu heading. The pseudo-elements work fine for a regular link outside of the menu. How

1条回答
  •  日久生厌
    2021-02-19 12:57

    If you're going to absolutely position the pseudo elements, you need to give their parent a position value, same as with non-pseudo elements.

    Just add:

    .menuheader {
        position : relative;
    }
    

    Here is an updated version of your JSFiddle (the only changes are adding the above code and making the background of the pseudo elements a solid color for demonstration): http://jsfiddle.net/99Aq8/1/

    0 讨论(0)
提交回复
热议问题