【发布时间】:2012-02-12 16:14:23
【问题描述】:
我正在构建一个博客,我只想使用 Masonry 在有序的网格中显示每篇博客文章的相关图像。当用户单击图像时,博客文本内容将显示在图像下方(在同一页面上)。由于某种原因,当我添加点击功能时,隐藏的内容不会显示出来。我对 on() 事件处理程序(由于 Masonry 是必需的)不太熟悉,并且可能有一些明显的东西我遗漏了。发生的情况是我在 DOM 中看到元素得到 display: 块,但它们没有显示出来。
HTML -
<?php get_header(); ?>
<div id="posts" class="clearfix">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post">
<a class="view" href="#"><?php the_post_thumbnail(465, 999) ?></a>
<div class="overlay">+</div>
<article>
<a href="#" class="close">x</a>
<h1><?php the_title() ?></h1>
<hr>
<?php the_content() ?>
<span><?php the_date('Y/d/m') ?></span>
</article>
</div>
<?php endwhile; endif; ?>
</div>
<div class="navigation">
<?php next_posts_link(); ?>
</div>
<?php get_footer(); ?>
JavaScript -
var $container = $('#posts');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector: '.post',
columnWidth: 475,
isAnimated: true
});
});
$(document).on("click", "a.view", function(){
if(!$(this).parent().find('article').is(':visible')){
$(this).parent().find('article').slideDown(250);
}
else {
$(this).parent().find('article').slideUp(250);
}
e.preventDefault();
});
$(document).on("mouseover", "a.view", function(){
$(this).parent().find('.overlay').stop().animate({ opacity: 1 }, 250);
});
$(document).on("mouseout", "a.view", function(){
$(this).parent().find('.overlay').stop().animate({ opacity: 0 }, 250);
});
【问题讨论】:
-
你有一个网址,我可以看到真实的东西,用 css 和所有?我试过你的代码有和没有砖石,它的工作原理和我猜应该的一样,所以它可能是砖石和你的css的组合导致它......
标签: jquery jquery-masonry