首页 \ 问答 \ CSS:创建随机大小矩形的镶嵌墙(CSS: Create a tessellating wall of random sized rectangles)

CSS:创建随机大小矩形的镶嵌墙(CSS: Create a tessellating wall of random sized rectangles)

我想创建一个包含在不同颜色矩形内的引号墙。

显然,引号将是不同的长度,我希望矩形是随机大小的宽度 - 这意味着高度将相应地调整大小。

我正在使用浮动:左,但这留下了很多空隙。 如果矩形可以镶嵌,那将是很好的。

我不太确定这个问题是否适合2D包装问题或其他问题,例如: 以最佳方式将矩形装配在一起 。 如果是这样,我不知道如何将解决方案转换为php / css / jquery。 否则,任何其他想法会有所帮助:)


I want to create a wall of quotes that are contained inside different colored rectangles.

Obviously, the quotes will be different lengths and I want the rectangles to be randomly sized widths - which will mean the heights are going to be correspondingly sized.

I'm using float: left, but this leaves lots of gaps. It would be great if the rectangles could tessellate.

I'm not quite sure if this problem fits the 2D packing problem or other questions such as this one: Fitting rectangles together in optimal fashion. If it does, I don't know how to translate a solution into php/css/jquery. Otherwise, any other thoughts would help :)


原文:https://stackoverflow.com/questions/7901217
更新时间:2024-04-03 08:04

最满意答案

可以通过以下方式简化代码。 将一组自动完成结果添加到try的每个节点。 在try中插入单词时,同时将自动完成集添加到每个访问节点。 要执行自动完成,只需返回相应节点的自动完成集。

此解决方案为getWordsWithPrefixgetWordsWithPrefix添加了一行,同时完全消除了对buildWords的需求。


The code may be simplified in the following way. Add a set of autocomplete results to each node of the try. When inserting a word in a try, simultaneously add autocomplete set to each visited node. To perform an autocomplete, just return autocomplete set for the corresponding node.

This solution adds one line to insertWord and getWordsWithPrefix, while completely remove the need of buildWords.

相关问答

更多
  • 在下面的图片中, MyClass.java有一个空心的J ,因为它明确地从构建的源中排除: 你可以去项目的属性,“ Java Build Path ”部分,“ Source ”选项卡,看看是否设置了一些排除过滤器? 例如通常定义: **/Test*.java 首先排除任何单元测试类(当你有一大组源代码,并且不希望在自动完成过程中使用测试类,或者不希望在源搜索过程中考虑它们时)。 In this following picture, MyClass.java has a hollow J, because ...
  • 我不确定你的网页出了什么问题。除了在输入标签上遗漏了一个结束标签之外,每件事情似乎都已到位。 should be 大多数浏览器都是宽容的,你可能会对此感到满意。 我开箱即用你的代码,它可以工作。我已经为你编译了一个示例项目,并确保你有一个类似的设置使用母版页。 I am not sure what is getting wrong with your web page.Other than missing a closing t ...
  • 我不确定你为什么要做$.noConflict() 。 而且,你好像都在调用jQuery库; 有时使用“$”,有时使用“jQuery”。 另外,如果你把东西放在你应该使用$(document).ready(); 。 让我们简化...... ...
  • 在将“id”属性添加到自动完成功能后,它现在正在演示中显示。 在一个单独的项目中,它没有“id”属性。 看起来像个bug。 It is working now as shown in demo after adding the "id" attribute t ...
  • 我们可以确信代码没有问题。 这里有一件事,你的意思是自动完成不起作用 ? 你说的下面这行很有趣: 输入具有类ui-autocomplete输入,但自动完成仍然无效。 为了使其工作,我们需要jqueryui CSS 。 我说这是因为与CSS的链接不在小提琴中。 是这样吗? 编辑: 另外需要注意的是:我相信自动填充HTML属性与浏览器自动完成以前使用的文本相关,与jQueryui功能无关。 We can be very sure that there is no issue with the code. One ...
  • 你需要确保库被添加到jsfiddle 我已经为你添加了链接(注意左侧添加了jquery库) http://jsfiddle.net/nz3Luyu8/ JAVASCRIPT $(function() { var availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskel ...
  • 您可以通过转到首选项 - >常规 - >内容类型并添加* .drl作为Java源的子类型来实现此目的。 这将使得Java内容辅助工作在.drl文件中,但不幸的是它会做更多的事情。 它会将您的drl文件发送到Java编译器,它将显示格式错误的Java代码的错误标记(并且drl文件包含大量的代码)。 您可以通过各种偏好关闭大量的内容: 将* .drl文件添加到类路径的排除过滤器中,或者将它们放在类路径之外。 转到首选项 - > Java - >编辑器并禁用“在键入时报告问题”。 drl文件中没有错误标记。 但是 ...
  • 可以通过以下方式简化代码。 将一组自动完成结果添加到try的每个节点。 在try中插入单词时,同时将自动完成集添加到每个访问节点。 要执行自动完成,只需返回相应节点的自动完成集。 此解决方案为getWordsWithPrefix和getWordsWithPrefix添加了一行,同时完全消除了对buildWords的需求。 The code may be simplified in the following way. Add a set of autocomplete results to each nod ...
  • 基本上,你有一个源图像和一个网格。 网格开始像一个完美的正方形网格,但变形。 算法是 For Each section of the mesh For Each pixel of the section (x, y) = Location in original photo for this pixel // (floating point) color = ColorFromOriginal(x, y) // this needs to blend nei ...
  • 试试这个。 你根本不需要自动完成。 var availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", " ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)