动态调整网格单元格的大小

编程入门 行业动态 更新时间:2024-10-11 09:20:26
本文介绍了动态调整网格单元格的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图创建一个两行三列网格布局:

这很简单。我想知道如何扩展任何一个给定的单元格,导致其他单元格围绕扩展单元格重新排列:

我不是在寻找纯粹的CSS解决方案。我有它的工作,但我根据我扩展的细胞对绝对位置进行硬编码,这感觉很脏:/ Thanks! 解决方案

您可以像使用树形图一样使用装箱解决方案。您可以对矩形进行排序并创建一棵树并沿着2轴分割树。选择下一个项目并将其放在最佳空闲空间中。然后重新启动该过程。有一个jquery treemap插件。这里是一个例子,但包装光照贴图。这是一个伪代码: www.blackpawn/texts/lightmaps/ 。

I am attempting to create a two-row, three-column grid layout:

This is pretty simple. I am wondering how to expand any one of the given cells, causing the other cells to rearrange around the expanded cell:

I am not looking for a pure-CSS solution necessarily. I have it working, but I am hardcoding absolute positions based on what cell I am expanding, which feels dirty :/ Thanks!

解决方案

You can use a bin-packing solution like a treemap. You can sort the rectangles and create a tree and split the tree along the 2 axis. Pick the next item and put it in the best free space. Then restart the process. There is a jquery treemap plugin. Here is an example but packing lightmaps. It's a pseudo-code:www.blackpawn/texts/lightmaps/.

更多推荐

动态调整网格单元格的大小

本文发布于:2023-11-23 04:14:25,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   单元格   大小   动态

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!