Answer the question
In order to leave comments, you need to log in
Fixing the menu from tabs on the top of the page. How to make the information displayed in full when switching tabs?
The site has tabs. When scrolling, tabs in the mobile version are fixed at the top as a collapsed menu, but the problem is that when switching tabs at the top, the content is displayed not from the beginning, but from the place where the previous tab was viewed. How to make it so that when switching the tab, the full content is displayed i.e. at first.
<div id="views-bootstrap-tab-1" class="views-bootstrap-tab-plugin-style">
<ul class="nav nav-tabs nav-justified fixed">
<li class="in toggle active" style="height: auto;">
<a href="#tab-1-0" data-toggle="tab">Вкладка</a>
<span></span></li>
<li class="toggle collapse" style="display: block; height: 0px;">
<a href="#tab-1-1" data-toggle="tab">Вкладка</a>
<span></span></li>
<li class="toggle collapse" style="display: block; height: 0px;">
<a href="#tab-1-2" data-toggle="tab">Вкладка</a>
<span></span></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab-1-0">Инфо</div>
<div class="tab-pane" id="tab-1-0">Инфо</div>
<div class="tab-pane " id="tab-1-0">Инфо</div>
</div>
var windowTop = $(window).scrollTop();
var sectionStarts = $('#sectionStarts').offset().top;
var sectionEnds = $('#sectionEnds').offset().top;
if (windowTop > sectionEnds) {
$('ul.nav.nav-tabs').removeClass('fixed');
} else if (windowTop > sectionStarts) {
$('ul.nav.nav-tabs').addClass('fixed');
} else {
$('ul.nav.nav-tabs').removeClass('fixed');
}
}
ul.nav.nav-tabs.fixed {
position: fixed;
top: 23px;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question