【发布时间】:2017-08-01 15:01:44
【问题描述】:
试图弄清楚当我们改变列的高度时如何防止列移动。 看JSFiddle,尝试点击3栏链接看:https://jsfiddle.net/g305643f/1/
如果您想提供非多列的解决方案 - 在以下条件下,可以使用其他方法来实现构建列的任务:
在桌面上我们需要这个:
1 3 5
2 4
在平板电脑上:
1 4
2 5
3
没有找到使用 flex/float/inline-blocks 的解决方案,所以用多列来解决,现在发现这个问题。
$(document).ready(function() {
$(".open").click(function(e){
$(this).next().slideToggle();
e.preventDefault();
});
});
.sections {
-webkit-column-gap:41px;
-moz-column-gap:41px;
column-gap:41px;
-moz-column-count: 3;
-webkit-column-count: 3;
column-count: 3;
}
.section {
-webkit-column-break-after: avoid;
-webkit-column-break-before: avoid;
break-inside: avoid;
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
}
.open {
display: block;
text-transform: uppercase;
margin: 10px 0;
font-family: "Helvetica";
}
.hidden {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="sections">
<div class="section">
<img src="http://placehold.it/300x300" />
</div>
<div class="section">
<img src="http://placehold.it/300x310" />
</div>
<div class="section">
<a href="#" class="open">Open & raise height</a>
<div class="hidden">
<img src="http://placehold.it/300x320" />
</div>
<img src="http://placehold.it/300x330" />
</div>
<div class="section">
<img src="http://placehold.it/300x340" />
</div>
<div class="section">
<a href="#" class="open">Open & raise height</a>
<div class="hidden">
<img src="http://placehold.it/300x320" />
</div>
<a href="#" class="open">Open & raise height</a>
<div class="hidden">
<img src="http://placehold.it/300x320" />
</div>
<img src="http://placehold.it/300x350" />
</div>
</div>
【问题讨论】:
-
任何小提琴代码都应该包含在您的帖子中。
-
添加了sn-p,看
-
一旦页面加载,列是否会改变,还是只是在加载之前项目数量未知?网格 CSS 会做还是需要表现得像 masonry js-script?
标签: html css css-multicolumn-layout