2013-12-12 84 views
1

在固定高度的容器中,我想让标签内容滚动,并将标签留在顶部。使用Bootstrap滚动标签内容

<div class="bs-example bs-example-tabs" style="height: 200px; border: 1px solid black"> 

    <ul id="myTab" class="nav nav-tabs"> 
     ...  
    </ul> 

    <div id="myTabContent" class="tab-content"> 
     This is long and must scroll, tabs must stay on top 
     .... 
    </div> 

</div> 

http://jsfiddle.net/graemian/Wxr9d/3/

我发现使用柔性布局的解决方案:

http://jsfiddle.net/graemian/wefPL/1/

(铬只),但肯定还有另一个更简单的方法?

回答

2

您可以模拟滚动使用溢出:汽车

.bs-example{ 
    position: relative; 
} 

.tab-pane{ 
    position: absolute; 
    top: 42px; 
    bottom: 0; 
    right: 0; 
    left: 0; 
    overflow:auto; 
} 
+0

很聪明!有没有办法绕过固定的“42px”? –

+0

你可以简单地添加'height:180px; overflow:auto;'到'.tab-pane'块,其中180px = .bs-example的高度 - .nav-tabs的高度。并删除位置:absoulte和其他样式 –