Support » Themes and Templates » Jquery Masonry feature image margin/padding issue

  • I’m currently working on a theme with the Jquery Masonry plugin integrated. This plugin makes it possible to float your elements in a nice way, instead of keeping big gaps while floating.

    Masonry is a layout plugin for jQuery. Think of it as the flip side of CSS floats. Whereas floating arranges elements horizontally then vertically, Masonry arranges elements vertically then horizontally according to a grid. The result minimizes vertical gaps between elements of varying height, just like a mason fitting stones in a wall.

    All the featured images of the page should be stacked seamlessly without gaps between the elements. ‘Seamlessly’ is the idea, but each picture keeps approx. 3 pixels of white space below the picture. I cannot succeed to remove this. See an example of the website here.

    When replacing the <?php the_post_thumbnail('full', array('class' => 'thumb')); ?> with <div style="width:420px; height:233px; background-color:#FC0;"></div> it works perfectly. No whitespace and everything is stacked seamlessly. The issue is probably the <img> inside the <div class="box">. I’ve tried to style the <img> in various different ways without success. Any suggestion is welcome.

    index.php

    <div id="wrapper">
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    		<div class="box">
            	<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
                	<!-- TEST DIV.
                    <div style="width:420px; height:233px; background-color:#FC0;"></div>
                	-->
    			<?php the_post_thumbnail('full', array('class' => 'thumb')); ?>
    
                    <span class="thumb-slide">
                        <ul>
                            <li><?php the_title(); ?></li>
                            <li><?php the_subtitle() ?></li>
                        </ul>
                    </span>
                 </a>
    		</div>
    
    	<?php endwhile; ?>
    
    	<?php else : ?>
    
    		<h2>Not Found</h2>
    
    	<?php endif; ?>
    </div>

    CSS

    #wrapper {
    	padding: 0;
    	margin-top: 20px;
    	margin-right: 20px;
    	margin-bottom: 80px;
    	margin-left: 20px;
    	}
    
    .box {
      float: left;
      margin: 0px;
      padding: 0px;
    	}
    
    .box img {
    	margin: 0px;
    	padding: 0px;
    	overflow: hidden;
    	}
    
    .thumb {
    	margin: 0px;
    	padding: 0px;
    	}

Viewing 2 replies - 1 through 2 (of 2 total)
  • Jason Paul

    (@jasontrasaterracom)

    I believe I have a similar problem. I’m trying to float in a Featured image slider but have it be a different size than the rest of the masonry divs. It actually seems impossible, as if the ability to float in non-masoned objects of a different size is just not part of the plugin. I’m making a site to be 100% browser size, so it would be nice if the masonry divs would float around my non-masonry featured slider. At the moment, the only way for this to work is to keep the featured slider the same width as all the masonry divs. Not an appealing design though.

    Same issue here, with jQuery Masonry. Looks like it’s stacking, but won’t push my thumbnails up flush with the others. jQuery is enqued properly, etc etc, I think it’s a styling issue as well…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Jquery Masonry feature image margin/padding issue’ is closed to new replies.