• I have created a staff thumbnail directory for a client using the native WP gallery. The gallery is 4 columns across but the last row has only 3 gallery items. My client would like to center the last row inside the enclosing gallery div. Can anyone think of a way to target only the gallery items within a specific row and change their properties so that the row centers relative to the other rows?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try using Firefox with the Firebug add-on for this kind of CSS troubleshooting. Or use whatever developer tool is available in your web browser.

    Thread Starter figure2

    (@figure2)

    @emsi: That was what I tried first. I was hoping that each row might be wrapped in a div or some other kind of container. At least then I could assign the row wrapper a property of inline-block and set the left & right margins to auto.

    But that is not the case. Each gallery item is loose in its row and the rows are only separated by
    tags.

    If you are not familiar with the native WP galleries, create one and see for yourself.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    I’m pretty sure Esmi is familiar with native WordPress galleries. ??

    But that is not the case. Each gallery item is loose in its row and the rows are only separated by
    tags.

    Do you have a link for us to look at? Esmi’s advice is right on target *Jan waves to Esmi* but having something live to look at that illustrates it usually works out better.

    Thread Starter figure2

    (@figure2)

    Thanks Jan. The site in question isn’t ready to show so I threw together a generic sample using the Twenty Thirteen theme.
    https://gallery-test.markhannondesign.com/

    As you can see, there are 4 columns and 3 rows. The bottom row is only 3 columns. The client wants to center the bottom row.

    Now I could certainly target the first thumbnail in the third row with “#gallery1 .gallery-item:nth-child(9){}.” But what happens if they add another staff member? The gallery layout would break and I would get a call from an unhappy client. Good web design anticipates these possibilities which is why esmi’s answer surprised me.

    Rewriting the gallery shortcode function is a bit beyond my skill level so I am thinking that I should ask my client if they can live with the last row aligned left.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Centering one row inside a WP gallery’ is closed to new replies.