• Resolved Bryce Corkins

    (@sekatsim)


    I’m having trouble center aligning an image gallery.

    https://www.brycecorkins.com/portfolio/2009/weather-on-the-bay/

    I’ve tried setting the left and right margins to ‘auto’ on the gallery container, but it doesn’t seem to have any effect. Interestingly, if I set the width of the container to ‘auto’ instead of ‘100%’, and manually set a left margin (like.. 150px), I can center the gallery.. but I’d like to somehow auto-center it– without having to manually set a left margin for every gallery.

    Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • You site doesn’t seem to be responding…

    Thread Starter Bryce Corkins

    (@sekatsim)

    It seems to be working ok now. I’m not super happy with the host.. sometimes it takes a reload to get it going.

    Got it now…

    Get rid of float:left in:

    .gallery {
    clear:both;
    float:left;
    margin-bottom:10px !important;
    width:100%;
    }

    and apply a width. 306px seems to work quite well with that particular gallery.

    Thread Starter Bryce Corkins

    (@sekatsim)

    Yes… that does work. But is there any way of automatically setting the width, instead of having it do it for every post?

    I played around with media.php, thinking I could do something like set the width to the thumbnail size x the number of thumbnails.. but I don’t know wp code very well. Would you know how to do this?

    $output = apply_filters('gallery_style', "
    		<style type='text/css'>
    			#{$selector} {
    				margin: auto;
                                    width: {$itemwidth*$attachments}% (or something like that)
    			}
    			#{$selector} .gallery-item {
    				float: {$float};
    				margin-top: 10px;
    				text-align: center;
    				width: {$itemwidth}%;			}
    Thread Starter Bryce Corkins

    (@sekatsim)

    Ok. I got it. Had to do some CSS tricks with the gallery container. I posted detailed instructions here:

    https://www.brycecorkins.com/blog/2010/center-align-a-wordpress-image-gallery/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Center-aligning an image gallery’ is closed to new replies.