CSS adjust style of element where its child does have class

Is there a pure CSS way to adjust styling of an element where its only child does not have a class?

For example:

Read More
<a><img class="avatar pro"></a>
<a><img class="avatar"></a>

And I only want to style “a” containing a child with the class “pro”?

Background is the following:
In Buddypress, you have a hook to add a class for avatars:

add_filter( 'bp_core_avatar_class', 'filter_bp_core_avatar_class', 10, 4 );

However, since :before / :after-pseudo-classes do not work on images, I need to be able to adjust the wrapping container.

Thanks!
Raphael

Related posts

Leave a Reply

3 comments

  1. It seems that there is a discussion about :before and :after for elements that do not contain text.

    However, there is a pure CSS way. In this discussion here

    Does :before not work on img elements?

    TimPietrusky demonstrates it (scroll down). The solution is here at the CodePen:

    http://codepen.io/TimPietrusky/pen/xpesA

    The clever guy uses the content attribute to set text, and once there is text, :after and :before will/should/could apply. Then he designs :before and :after to match his expectations. I like it, but it is a classical “misuse” of side effects that has to be managed on many browsers.