WordPress.org

Ready to get started?Download WordPress

Forums

dynamic pseudo class needed? first-child? dunno! help! (2 posts)

  1. prkekrul
    Member
    Posted 5 years ago #

    So, what I want to do is have the first image that shows up on a blog post fit the width of the post so it looks like a headline image. however, I need the text that comes after it in the <p> elements to have a right and left padding of 10px and I want it to do the same for each and every <p> that comes after an <img>

    This is what I've got...and it works for the <img> element if I switch the P and IMG, but that defeats the purpose of what I want to do...so! Here's what I've got so far. Any input is greatly, greatly appreciated. It looks so simple but it's just not working and I'm relatively new with pseudo-classes...so I've got no idea:

    img > p:first-child {
    	padding-left: 10px;
    	padding-right: 10px;
    }

    Thanks!

  2. bekabug
    Member
    Posted 5 years ago #

    Can you give me a link or show me a sample of your code?

    I don't think that will work because the paragraph tag won't be inside the image tag. You might be able to reverse it and have something like:

    <p><img src="#" />Text Goes Here</p>

Topic Closed

This topic has been closed to new replies.

About this Topic