简体   繁体   English

多行制表符

[英]multi-line tabs

I am struggling with a HTMl/Css issue. 我正在努力解决HTM1 / Css问题。 I am creating tabs using ul and li. 我正在使用ul和li创建选项卡。 The list of tabs is dynamic and can extend upto 10 tabs. 选项卡列表是动态的,最多可以扩展到10个选项卡。 The problem is that the list breaks on 100% width and the tabs overlap. 问题在于列表在100%的宽度上折断并且选项卡重叠。 Is it possible to calculate when the list reaches near to 100% width, so I can create a second set of tabs? 是否可以计算列表何时达到接近100%的宽度,以便创建第二组选项卡?

Here is the link to an example. 这是一个示例的链接。

http://jsfiddle.net/syEJx/5/ . http://jsfiddle.net/syEJx/5/

The upper text of tabs 8,9, and 10 get cut off. 选项卡8,9和10的上部文本被切除。 I want to avoid that 我想避免那个

Thanks 谢谢

CSS (without the help of Javascript) cannot calculate dimensions in that manner but if your li's were floated within a ul with no height limit and a constant width then your tabs would populate left to right and top to bottom. CSS(没有Javascript的帮助)无法以这种方式计算尺寸,但是如果您的li漂浮在没有高度限制和恒定宽度的ul中,那么您的标签将从左到右,从上到下填充。 Another option might be to style your ul to display:block and your li's to display:inline. 另一个选择可能是将ul设置为display:block,将li设置为display:inline。 That might be better since the ul would expand around the li's. 这样可能会更好,因为ul将在li周围扩展。 I think that's the behavior you are looking for. 我认为这就是您要寻找的行为。

How about this? 这个怎么样?

Live Demo 现场演示

在此处输入图片说明

The new CSS: 新的CSS:

.tabs li
{
    display: inline-block;
    margin: 0 0 15px 0;

    /* ie7 hacks */
    zoom:1;
    *display: inline;
    _height: 20px
}

It includes hacks necessary to make it work acceptably in IE7. 它包含一些必要的技巧,以使其在IE7中可以正常工作。 If you don't care about IE7, feel free to remove those three lines. 如果您不关心IE7,请随时删除这三行。

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

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