WordPress.org

Ready to get started?Download WordPress

Forums

Gallery's clear:both clears too much (5 posts)

  1. datiger
    Member
    Posted 4 years ago #

    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?

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    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.

  3. photocurio
    Member
    Posted 4 years ago #

    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
    	{
    	display:none;
    	}
  4. photocurio
    Member
    Posted 4 years ago #

    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.

  5. not2comply
    Member
    Posted 4 years ago #

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


    .gallery br {
    display:none;
    }

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags