CSS 水平行中等宽元素的任意数量

发布于 2024-12-09 18:58:43 字数 336 浏览 5 评论 0原文

我想创建一个像这样的进度跟踪器: https://hmv.com/hmvweb/checkoutRegister.do< /a> 但我需要它流畅,以便周围的 DIV 可以改变其宽度。我可以给每个列表元素一个百分比宽度,但此外还会有具有不同列表元素数量的进度跟踪器。列表元素应该填满整个宽度,并且它们应该具有相等的宽度。

这不是一个容易的挑战,对吧?

有谁知道如何创建解决方案?我尝试了 display: table 属性,它们并排放置,但不像想要的那样(元素宽度错误)。

I want to create a progress tracker like this one: https://hmv.com/hmvweb/checkoutRegister.do
but I need it fluidly so the surrounding DIV can change its width. I could give each list element a percentage width, but furthermore there will be progress trackers with different count of list elements. The list elements should fill the complete width and they should have a equal width.

Not a easy challenge, right?

Does anyone have a idea how to create a solution? I tried the display: table properties, they are positioned side by side but not like a wanted it (wrong width of the elements).

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

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

发布评论

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

评论(2

驱逐舰岛风号 2024-12-16 18:58:43

为什么不直接将元素包装在没有列表样式、display:block 且宽度为 100% 的

    中。然后让每个进度项都在一系列

  • 中,这些
  • 具有 float:left、无列表样式和相等的 百分比 宽度?这需要您根据项目数量为
  • 设置 css 样式,但如果您使用 CMS 或可以编写一些 JS,那么您可以附加正确的 < ;li> 相应的样式。

Why not just wrap the elements up in an <ul> which has no list-style, display:block and a width of 100%. Then have each progress item within a series of <li> which have a float:left, no list style and an equal percentage width? This would require that you have a css style for the <li> based on the number of items but if you are using a CMS or can write some JS then you could attach the correct <li> style accordingly.

彩虹直至黑白 2024-12-16 18:58:43

我尝试了显示:表格属性,它们并排放置
侧面但不像想要的那样(元素宽度错误)。

如果您基于 display: table 的解决方案感到满意,除了事实上,元素的宽度不相等,那么最简单的方法就是解决这个问题。

您可以通过应用table-layout:fixed 任何具有 display: table 的内容。

参见: http://jsfiddle.net/JBfE7/

I tried the display: table properties, they are positioned side by
side but not like a wanted it (wrong width of the elements).

If you're happy with a display: table-based solution, other than the fact that the width of the elements aren't equal, then the simplest thing to do is fix that problem.

You can do that by applying table-layout: fixed to whatever has display: table.

See: http://jsfiddle.net/JBfE7/

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