Self clearing floats for portfolio using grid_x_of_12
-
Hi Ahortin,
I’ve been building a portfolio page for use in Quark using a custom post type. I’ve basically followed the tutorial here.
To fit better with the theme and to make it responsive, I’ve attempted to create a new page template (using the full width template supplied with Quark as a basis) and create a new sidebar a la how you created the sidebar-front for use with the front page template.
Within the sidebar-portfolio.php file that I’ve created each portfolio item is contained in a
div
with a class of “grid_3_of_12” (as I want to have a maximum of four portfolio items per row). This sets the width of the portfolio item boxes fine, but I’m having problems clearing the float on the fourth item so that the fifth item jumps down to the far left on a new row – instead it sits underneath the fourth item because there’s space for it.Is it possible to use the grid_x_of_12 classes to arrange items in 4×4 grid, or am I limited to using them on a single row? If I was hard coding the portfolio page I would just assign a
clearfix
class to the relevant items, but as the portfolio posts are pulled dynamically by WordPress I’m stuck. Using an nth-child rule might work but its support is limited in IE…I’m racking my brains trying to think of a solution (I’ve spent way to long on this!) – any ideas on where I’m going wrong? The code for the sidebar is below:
<?php /** * This is a sidebar that Rob has coded based on the sidebar-front widget * * Next line calls the latest portfolio posts */ query_posts('post_type=portfolio&posts_per_page=9'); ?> <div id="secondary" class="portfolio-sidebar row clearfix"> <!-- Starting the loop to call portfolio post types and trim titles --> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $title= str_ireplace('"', '', trim(get_the_title())); $desc= str_ireplace('"', '', trim(get_the_content())); ?> <div class="col grid_3_of_12"> <div class="widget-area" role="complementary"> <div class="portfolio-box"><!-- Container for portfolio items --> <div><h3><?=$title?></h3></div><!-- Item title --> <div><?php the_post_thumbnail(); ?></div><!-- Item image --> <div><p><?php print get_the_excerpt(); ?></p></div><!-- Item excerpt --> <div><?php $site= get_post_custom_values('projLink'); if($site[0] != ""){ ?> <p><a href="<?=$site[0]?>">Read more</a></p> <?php }else{ ?> <p><em>Live Link Unavailable</em></p> <?php } ?></div><!-- Item link --> </div><!-- /.portfolio-box --> </div> <!-- /.widget-area --> </div> <!-- /.col.grid_3_of_12" --> <?php endwhile; endif; ?> <!-- Finish loop calling portfolio post types and trimming titles --> </div> <!-- /#secondary.row -->
- The topic ‘Self clearing floats for portfolio using grid_x_of_12’ is closed to new replies.