// contains tab headers and contents
var tabsContainer = $('.tabs');
// this is a UL element containing the tab headers
var currentUlElement = $('.tabNavigation');
// this are the LI elemets which are the actual tabs
var currentLiElements = currentUlElement.children('li');
// we can only have 6 tabs plus the '+' tab (total 7) in a row.
// if there's mroe than that we need to sort the overflow
if (currentLiElements.length > 7) {
// remove all current tab headers
currentUlElement.remove();
// create new tab headers container
var newUlElementRow = $('<ul />');
// make the list items appear like tabs
newUlElementRow.addClass('tabNavigation');
// add the new tabs header container to the front of the main tab/content container control
tabsContainer.prepend(newUlElementRow);
for (var index = 0; index < currentLiElements.length; index++) {
// if one row of tabs is complete
if (index == 6) {
// create a new tab headers container
newUlElementRow = $('<ul />');
// make the list items appear like tabs
newUlElementRow.addClass('tabNavigation');
// add the new tabs header container to the front of the main tab/content container control
tabsContainer.prepend(newUlElementRow);
}
// add the tab/list item to the new tab headers container
newUlElementRow.append(currentLiElements.get(index));
}
// re-enable the tab click actions
trackNetPeople.SetupTabs();
}
ul {position:relative;}
ul li {padding:3px 10px;height:20px}
ul li:last-child{position:absolute}
ul li:not(:last-child) {float:left;color:green;margin-top:20px; /*height of li*/}
7条答案
按热度按时间fgw7neuy1#
非常感谢各位的回答。但是可能我的问题不清楚。另外,我是www.example.com的新手stack-overflow.com,所以请对我放松点:)
无论如何,我昨晚使用jQuery解决了这个问题,删除了当前的选项卡并重新创建了它们--但是这次在每个ul/行中添加了固定数量的列表项/选项卡。如果每个选项卡的数量超过了固定数量,则为它们创建一个新的ul元素。每个UL元素将像一个新行一样
下面是我的javascript/jQuery
cfh9epnr2#
我可能没有很清楚地理解你的问题,但你似乎试图将最后一个tab li元素与其他li元素分开:
这可以通过以下方式实现:
并使最后一个li成为第一个li,使用jQuery,如下所示:
nx7onnlm3#
我不认为你可以,因为你没有使用任何“行”。它只是简单的文本被推到下一行。
如果你的标签来自数据库,你可以用PHP来处理它们,用数组来排序,但是你仍然需要另一种方式来显示它们。表格可能是一个很好的选择(在这种情况下)。
busg9geu4#
你可以这样写:
HTML格式
CSS格式
检查此http://jsfiddle.net/mxgNT/
jtoj6r0c5#
我不知道要使用哪种类型的语言来实现这一点,但这里有一个
jQuery
解决方案:实时示例:http://jsfiddle.net/gzZ6C/1/
jQuery查询器
UPDATE:添加了浮动样式
zi8p0yeb6#
乍听起来可能有点令人困惑。但并不太难。
CSS:
现场演示:
http://jsfiddle.net/f6GEp/
ymzxtsji7#
不看标签的css风格很难判断。但是考虑使用一些框架中的标签界面,比如bootstrap标签,foundation标签或者jQuery ui标签。如果你想要一个高级的响应标签解决方案,可以看看zozo标签,里面有很多例子。
http://zozoui.com/tabs
欢呼声
Fari设计