简体   繁体   English

使砌体画廊在表单元格div中工作?

[英]Make Masonry gallery work inside table-cell div?

I'm currently loading some Masonry items into a table-cell, the problem is that the browser has trouble calculating the width of the table-cell so the Masonry elements won't realign themselves when I adjust the browser width. 我当前正在将一些Masonry项加载到表格单元中,问题是浏览器无法计算表格单元的宽度,因此在调整浏览器宽度时Masonry元素不会重新对齐。

This article seems to discuss a similar problem but I can't get it to work here 本文似乎讨论了类似的问题,但我无法在这里使用

The css looks like this and the Masonry Items are loaded into the #Gal1 element. css看起来像这样,并且“砌体项目”已加载到#Gal1元素中。

div#wrapper{display:table; height:100%; width:100%;}
div#sidebarWrapper{display:table-cell; min-width:40px; height:100%; background-color:#444;}
div#contentWrapper{display:table-cell; height:100%; position:relative;}
div#content{border-left:1px solid #ddd; border-top:1px solid #ddd; overflow:hidden; 
  padding-bottom:100px; margin-top:195px;}
div#masonryGal{max-width:1600px; position:relative; height:500px; overflow:hidden;}
#gal1{} 

I've seen around the web about making a transparent image 100% width so that it fills up the container with something? 我在网上看到过要制作100%宽度的透明图像,以使容器中充满某种东西? Is this the way to go and would I have to have it repeat inside the element #contentWrapper? 这是要走的路,我是否必须在元素#contentWrapper中重复它?

How would this affect my jquery? 这将如何影响我的jquery?

jQuery(document).ready(function($) {
    $('#gal1').masonry({
        singleMode: true,
        "gutter": 0,
        isFitWidth: true,
        isAnimated: true
    }).imagesLoaded(function() {
        $('#gal1').masonry('reload');
    });

Again, the problem here is that I'm using Masonry inside a table, I'm using this inside a responsive layout and it's just the situation I'm in right now so please no "use a div". 再次,这里的问题是我在表格中使用Masonry,在响应式布局中使用了它,这只是我现在所处的情况,所以请不要“使用div”。

absolute positioned elements (masonry use position absolute for blocks, to calculate their positions, and their container can't be display: table or table-cell) can't be inside table or table-cell 绝对定位的元素(砌体使用绝对位置作为块,以计算其位置,并且其容器无法显示:表格或表格单元格)不能在表格或表格单元格内

Update 更新

http://css-tricks.com/absolutely-position-element-within-a-table-cell/ http://css-tricks.com/absolutely-position-element-within-a-table-cell/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM