我正在尝试实现一个网站的主图像下的砖石画廊。我甚至不确定我是否已经接近成功。目前,缩略图在一行中,但只有四个到一行,而不是5个,并且它们不会相互填充空白,这显然是预期的结果。
下面是CSS:
#mason {
width: 950px; /* width of the entire container for the wall */
margin-bottom: 10px;
}
.brick {
width: 20%; /* width of each brick less the padding inbetween */
margin: 0;
display:inline-table;
}下面是HTML:
<div id="mason">
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('posts_per_page=100'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<div class="brick">
<div class="brick_featured_image">
<?php if ( has_post_thumbnail() ) {
$size=75;
?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Click to view: <?php the_title_attribute(); ?>">
<?php the_post_thumbnail( $size ); } ?>
</a>
</div>
</div>
<?php endwhile;?>
<?php $wp_query = null; $wp_query = $temp;?>
</div>下面是我添加到我的functions.php中的内容:
function mason_script() {
wp_enqueue_script( 'jquery-masonry' );
}
add_action( 'wp_enqueue_scripts', 'mason_script' );下面是我添加到页脚的脚本:
<script>
jQuery( document ).ready( function( $ ) {
$( '#mason' ).masonry( { columnWidth: 190 } );
} );
</script>我按照这个网站上的步骤操作:http://pastebin.com/y0D0NDSf
目前所有内容都可以在这里查看:http://cks.whiterabbitstudio.us/test-3/
提前感谢您的帮助!
发布于 2015-10-17 07:15:20
顺便说一下,这是声明了两次的CSS...which (加载站点的style.css文件两次)。
这应该会让你步入正轨:
.#wrapper {
padding: 5px 0px 40px 5px;
}
.brick {
margin: 0 0 5px 0;
}

https://stackoverflow.com/questions/33179440
复制相似问题