Nadeem Khan
Nadeem Khan

Reputation: 3434

Resize only the first image inside a WordPress post with CSS without affecting any other image

How can I resize only the first image present inside a WordPress post with CSS without affecting any other image inside the post. I have tried this so far with no success:

.texty p:nth-child(2) > img {
    width: 600px !important;
}

Here is the Demo

Upvotes: 2

Views: 58

Answers (1)

Josh Crozier
Josh Crozier

Reputation: 241128

You are trying to target the second p element, not the second child. You should therefore use :nth-of-type rather than :nth-child. Also, the img element isn't a direct child of the p element. It is a direct child of the child a element. The following selector will work given the provided markup:

.texty p:nth-of-type(2) > a > img

Upvotes: 2

Related Questions