javascript - How do I keep nav-tabs in boostrap fixed on the top while scrolling? - Stack Overflow

I have a Page in Rails which has 4-5 tabs. Each tab renders a partial (say a page). I want to be able t

I have a Page in Rails which has 4-5 tabs. Each tab renders a partial (say a page). I want to be able to keep the tabs fixed on the screen at the top or some margin from the top, even though a user scrolls down. I have used Bootstrap's <ul class="nav nav-tabs"> for tabs.

I have a Page in Rails which has 4-5 tabs. Each tab renders a partial (say a page). I want to be able to keep the tabs fixed on the screen at the top or some margin from the top, even though a user scrolls down. I have used Bootstrap's <ul class="nav nav-tabs"> for tabs.

Share Improve this question asked May 4, 2017 at 13:02 the railslearnerthe railslearner 1011 gold badge1 silver badge10 bronze badges 2
  • stackoverflow./questions/23020763/… – mxr7350 Commented May 4, 2017 at 13:04
  • I have already read it, and tried. The scrolling content overlaps the tabs. – the railslearner Commented May 4, 2017 at 13:06
Add a ment  | 

2 Answers 2

Reset to default 2

Add class navbar-fixed-top to nav ul

@media
only screen and (your condition)
{
 [class*="nav-tabs"] 
  {
    position: fixed;
    z-index: 9;
    background-color: #fff;
    margin-top: -11%; // adjust according to your need
  }
  // you are probably gonna mess up tab-content margin as well, so adjust it as I have shown below
  [class*="tab-content"] 
  {
    margin-top: 5%; // insert n% as per your need
  } 
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745624950a4636750.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信