Ready to get started?Download WordPress


add CSS for post only if certain aspect exists (5 posts)

  1. cclinton
    Posted 3 years ago #

    I'd like to set up a border at the bottom of posts on the index and archive pages. I have this set up in CSS and it works fine except when there is a thumbnail image (featured image). Then the line appears below the content and lines up with the center of the image.
    I tried adding css that forces the height of the post to a number just longer than the image and this solves the problem. However, this forces those posts with no featured images to also be the same height.

    Anyone know of a way I can write code that automatically loads css height for those posts with the image and leaves the height alone if no featured image exists?

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    link to your site?

    this is probably an issue with clearing floats or so;
    this is best checked with a link to a page with the issue.

  3. cclinton
    Posted 3 years ago #

    I yanked the height attribute from the post in the CSS and threw in a sample image so you could see what is happening.
    Here's the link to the test space: http://s88691088.onlinehome.us/pm2011/

  4. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    .post_mn {float:left;
    a.thumb img{margin-bottom:10px;/*optional*/}

    either added at the end of style.css, or edited in the corresponding styles, might work.

    only checked in firefox, not widely tested
    make backup copies of the theme files before editing

  5. cclinton
    Posted 3 years ago #

    Thanks. I threw in:
    width: 590px;
    as well as the previous code was only underlining the length of the text in the post. This way the line goes the whole way across.

    It appears to be working in Firefox, IE and Safari.

Topic Closed

This topic has been closed to new replies.

About this Topic