浮动div问题

发布于 2024-07-26 15:18:47 字数 208 浏览 2 评论 0原文

我有一个浮动 div,其中包含动态内容。 在第一行中,我需要四个 div,类似地在第二、第三、第四等中......我需要四个 div。 我可以将一个类分配给单个 div,它会自动生成其余的 div。 我的问题是我可以将最小高度设置为 div,但我无法设置最大高度,因为内容是动态创建的。 如果内容较低,则 div 不会排成一排。 由于这个原因,接下来的div也遇到了问题,如何安排这些div?

I have a floating div with dynamic content in it. In the first row i need four divs, similarly in 2nd, 3rd ,4th etc... i need four divs. I can assign a class to a single div and it will automatically generate the rest of the divs. My problem is i can set the min-height to a div, but i cannot set the max height as the content is dynamically created. if the content is low the divs are not sitting in a straight row. for this reasons, the up coming divs also getting problem, how to arrange these divs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

随波逐流 2024-08-02 15:18:47

让我们弄清楚这一点。 您有多个,每行有 4 个 DIV - 我们将它们称为单元格只是为了好玩。 您希望它们的高度在整行中相同,同时具有动态内容。 我会冒险建议你使用一张桌子。

Let's get this straight. You have multiple rows with 4 DIVs in each - let's call them cells just for fun. You want their height to be the same across the entire row while having dynamic content. I'm going to go out on a limb here and suggest you use a table.

泛滥成性 2024-08-02 15:18:47

在新行的第一个 div 上,添加 clear:both;。 这将使所有 div 排成一排。

div {float:left;border:1px solid #000;margin:20px;width:100px;}
.clear_both{clear:both;}
.one {height:100px;}
.two {height:50px;}
.three {height:200px;}
.four {height:150px;}

<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
<div class="four"></div>
<div class="two clear_both"></div>
<div class="three"></div>
<div class="four"></div>
<div class="one"></div>

On the first div the the new row, add clear:both;. That will make all the divs in a straight row.

div {float:left;border:1px solid #000;margin:20px;width:100px;}
.clear_both{clear:both;}
.one {height:100px;}
.two {height:50px;}
.three {height:200px;}
.four {height:150px;}

<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
<div class="four"></div>
<div class="two clear_both"></div>
<div class="three"></div>
<div class="four"></div>
<div class="one"></div>
风轻花落早 2024-08-02 15:18:47

您可以做的一件事是固定高度,并使用 overflow CSS 属性设置为 hide 来隐藏文本,并使用 title 属性以显示整个文本工具提示。

One thing you can do is make the height fixed, and use overflow CSS property set to hide to hide the text, and use the title attribute to show the whole text in a tooltip.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文