【发布时间】:2013-05-05 02:35:14
【问题描述】:
我无法让循环与 jquery Isotope 模块在经典 Masonry 样式布局中对齐。
所有浏览器都在控制台中正常加载脚本,但属性根本不起作用。 .item 类 div 元素的对齐方式都在左侧并水平堆叠。
Wordpress 是否有某种继承阻止它工作?我在没有其他插件的 wordpress 的默认 TwentyTwelve 主题上尝试这个,但它位于 positin:fixed; div 将其包裹到页面的下 50%。
<script type="text/javascript" src="http://<?php echo $_SERVER[HTTP_HOST]; ?>js/jquery.isotope.js">
$(document).ready(function(){
$('#container').isotope({
$container.isotope({
itemSelector:'.item'
});
masonry: {
columnWidth: 20
};
});
</script>
接着是对 html 的调用:
<div id="container" >
<div class="item">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php if (has_post_thumbnail()) {
the_post_thumbnail('thumbnail');
}?>
<h2><a href="<?php the_permalink() ?>" rel="<?php the_ID(); ?>" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php endwhile; endif; ?>
</div>
</div>
有了这些适用的 CSS 属性,我认为这不应该是问题......
#container {
position:relative;
}
.item {
width:50px;
height:auto;
border:1px;
}
这里有一个活生生的例子:justingaskin.com
【问题讨论】:
-
`$container` 是在哪里定义的?,我之前从未使用过
isotope,但看起来你调用了两次。 -
可能是。我仍然在处理后端开发 js。一个活生生的例子会有帮助吗?
-
一个活生生的例子会有所帮助。
-
查看
isotope文档后,您肯定设置错误。在下面查看我的答案。 -
添加了现场示例的 URL。感谢您的洞察力!
标签: javascript jquery css html wordpress