Support » Themes and Templates » Gallery’s clear:both clears too much

  • I noticed that native wordpress gallery has <br style=”clear: both” /> in it that breaks my theme.

    After the first thumbnail row there is this clearing element and while it should be clearing only inside of the post, it also clear outside.

    So there is a large gap between the first and the second gallery row. The gap ends in the same place as the sidebar ends.

    What do I have to do to contain this darn clearing element inside the post?

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi


    Forum Moderator

    Something like:

    .gallery br {clear:left !important;}

    in style.css might help. But, ideally, re-writing the gallery shortcode within the theme’s functions.php to:

    – remove the (completely incorrect) CSS block in the post body
    – replace the <br style="clear: both" /> with <br class="clear" /> that can then be controlled via the theme’s stylesheet

    is the best way to go.

    does anyone have a re-wriiten gallery shortcode function that works correctly?

    this bug is giving me trouble. putting in the

    .gallery br
    clear:left !important;

    does nothing. adding the following, as suggested in another thread, removes the gap but causes other display issues.

    .gallery br

    i’ve fixed my gallery by hacking the wp-includes/media.php.

    i’d just as soon not touch wp-includes, but hopefully this will be fixed in an upcoming release.

    I think this would help solving your br issue without touching the core

    .gallery br {

    .gallery:after {
    visibility: hidden;
    display: block;
    font-size: 0;
    content: " ";
    clear: both;
    height: 0;

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Gallery’s clear:both clears too much’ is closed to new replies.