gallery-style.scss

/** * Gallery Shortcode * * @since Wp 3.9 */ .gallery { margin-left : -0.375em; margin-right : -0.375em; @extend %cf; &-item { margin : 0; float : left; padding : 0.375em; img { width : 100%; } } &-columns-1 .gallery-item { width : 100%; float : none; } &-columns-2 .gallery-item { width : 50% } &-columns-3 .gallery-item { width : 33.3333% } &-columns-4 .gallery-item { width : 25% } &-columns-5 .gallery-item { width : 20% } &-columns-6 .gallery-item { width : 16.6667% } &-columns-7 .gallery-item { width : 14.2857% } &-columns-8 .gallery-item { width : 12.5% } &-columns-9 .gallery-item { width : 11.1111% } &-columns-2 .gallery-item:nth-child(2n+1), &-columns-3 .gallery-item:nth-child(3n+1), &-columns-4 .gallery-item:nth-child(4n+1), &-columns-5 .gallery-item:nth-child(5n+1), &-columns-6 .gallery-item:nth-child(6n+1), &-columns-7 .gallery-item:nth-child(7n+1), &-columns-8 .gallery-item:nth-child(8n+1), &-columns-9 .gallery-item:nth-child(9n+1) { clear : left; } }
WordPress 3.9 ships with the ability to add HTML5 support for galleries which will now use figure and figcaption to display images. This is a huge change for the better! Bonus: br tag used for clearing rows has been cleaned out as well. While all of this is good news for more semantic markup, one might now be left wondering how to style the new markup so that it displays properly. I am certain that there are as many ways to do this as there ways to eat a taco but let me share how I did it and see if you can improve it:

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.