WordPress.org

Ready to get started?Download WordPress

Forums

Want images to "stack" vs. show side-by-side (8 posts)

  1. tdcarp
    Member
    Posted 11 months ago #

    I posted on this some time ago but need to reopen the question. I have 3 images on a page that I'd prefer "stack" rather than display side-by-side.

    Four Creeks Maps

    I understand html and css fairly well and have assumed that WP floats the images which means the browser will attempt to fit them side-by-side if space allows.

    In an attempt to override this, the first post got a suggestion to add a statement to the theme's style.css that applied { clear:both } for all the caption IDs for the images. That worked at the time but isn't working now. The difference may be the size of the thumbnails.

    Regardless, that solution doesn't work for this page and these images.

    The question is: can I force images to NOT display side-by-side? Am I making the correct assumption that what WP is doing is floating the images?

    Although I have reasonable html and css skills I can't say the same for whoever takes over my role re: the site, so I'd prefer a solution that is durable (having to change the css whenever new images are uploaded is more work than I'd like to document).

    As much as I'd like a solution, I'd like to understand what WP is doing with these images that displays them side-by-side.

    Thanks

    Tom

  2. WPyogi
    Volunteer Moderator
    Posted 11 months ago #

    You can likely add "clear: both;" to the caption CSS:

    .wp-caption {
       clear: both;
    }

    Those maps are set to align right - presumably when you put them on the page. Right/left image alignment uses float - see:

    http://codex.wordpress.org/Inserting_Images_into_Posts_and_Pages#Image_Alignment

  3. WPyogi
    Volunteer Moderator
    Posted 11 months ago #

    Also, be aware that any changes should be made in a child theme or using a Custom CSS plugin so that your changes are not lost when the theme is updated.

  4. tdcarp
    Member
    Posted 11 months ago #

    Thanks, especially for the note about preserving the change if the theme is updated.

    I'll think through whether I want to make the change to the caption to consider whether I want the change to be that global.

    The question still remains: Why setting the caption IDs #attachment_nnn (for the 3 map images) to clear:both doesn't stack the images on the page I provided the link for?

    #attachment_665, #attachment_683, #attachment_685 { clear:both; }

  5. WPyogi
    Volunteer Moderator
    Posted 11 months ago #

    Looks like it's working just fine to me - have you cleared your browser cache? This CSS IS active/working:

    #attachment_665, #attachment_683, #attachment_685 {
        clear: both;
    }
  6. tdcarp
    Member
    Posted 11 months ago #

    Oops! You're exactly right. Sorry about that.

    You mentioned a couple options in your earlier posts, specifically a child css and a css plugin. These ideas were to avoid losing changes if the theme is updated. Would you expand briefly on each?

    I have good html and css skills so not much detail is needed.

  7. WPyogi
    Volunteer Moderator
    Posted 11 months ago #

    A child theme allows you to modify theme files without changing the parent theme - so then your changes won't be ovewritten when the theme is updated - http://codex.wordpress.org/Child_Themes

    Custom CSS plugins (Custom CSS Manager is a good one) - gives you a place to ADD CSS that will override the theme's CSS - again, so that it's not lost when the theme is updated.

    If you only want to make CSS changes, custom CSS is fine. If you're modifying other files (i.e. .php templates or functions.php), a child theme is the way to go.

  8. tdcarp
    Member
    Posted 11 months ago #

    Looks like either will be fine (although the child theme is a bit of overkill right now).

    The trick will be to come up with some css that allows me to avoid having to change it when the maps are replaced (i.e. not using the caption tags). One way would be to use the caption child of the maps page. That page should be static (i.e. not replaced) so it's ID is far more stable.

    Thanks again for your help.

Reply

You must log in to post.

About this Topic