简体   繁体   English

内联列表-有什么方法可以使项目等于最大宽度?

[英]Inline list - what approaches are available to make items equal to width of largest?

I'm creating a horizontal tab menu. 我正在创建一个水平选项卡菜单。

Because the tabs are responsive, I need to apply some rules: 由于选项卡具有响应性,因此我需要应用一些规则:

The maximum width of a tab is 264px 标签的最大宽度为264px

A tab width is the width of the text + 24px left and right; 制表符宽度是文本的宽度+左右24px;

However (here's the tricky bit), all tabs must be of equal size; 但是(这有点棘手),所有标签的大小必须相同;

If the total width of the tabbed area is less than the width available (the page container), all tabs are made equal to the largest width and centered within the space. 如果选项卡式区域的总宽度小于可用宽度(页面容器),则使所有选项卡均等于最大宽度并在该空间内居中。

If the total width is equal to or exceeds the width available (for instance mobile), tabs will be set to a fixed width (for instance 3 tabs = 33.33%) and the text will wrap where necessary. 如果总宽度等于或超过可用宽度(例如移动设备),则制表符将设置为固定宽度(例如3个制表符= 33.33%),并且文本将在必要时自动换行。

I'm trying to think of the best solution to this problem. 我正在尝试为该问题寻求最佳解决方案。

  • I'm guessing that a table based solution will work, however never used tables in anger, I'm not entirely sure.(if anyone has any advice on this, it would be appreciated) 我猜想基于表的解决方案会行得通,但是我不确定是否会激怒使用表(如果有人对此有任何建议,将不胜感激)

  • A javascript solution? 一个JavaScript解决方案?

  • Flexbox isn't really a viable solution as its not widely enough supported. Flexbox并不是真正可行的解决方案,因为它没有得到足够广泛的支持。

  • Are there any other css methods that I can make all tabs equal width? 还有其他我可以使所有制表符宽度相等的CSS方法吗?

All help advice appreciated. 所有帮助建议表示赞赏。

you'll agree that important thing here is greed, so there is easy solution for navs and tabs its with float. 您会同意,这里的重要事情是贪婪,因此,对于导航和带有float的制表符有简单的解决方案。

 ul{ list-style: none; } li{ width: 100%; } @media only screen and (min-width: 768px) { li{ float: left; //other styles for tabs } } 
 <ul> <li>1<li> <li>2<li> <li>3<li> <li>4<li> <li>5<li> </ul> 

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

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