
Sticky Nav with Vertical Slider
Sticky Nav with Vertical Slider
You can use Sticky Nav with Vertical Slider to animate a Section, Background, etc. and create user attractive UI components.
So if you are a person who wishes to develop a website, you have to know how to create 3D animations properly. Check out our tutorial and you can learn this techniques and use it on your web development. Below sections shows how to develop this animations.
How to create Sticky Nav with Vertical Slider? We are here to solve your problem. In this article we discuss how to create a hover effect animations. Before we start please read the below articles which easier you to understand the process, if you are new to development.
Step 1 – Add HTML
It’s too easy and simple. Just copy and paste below code in your HTML editor between <body> </body> tag as below.
<!-- Tabs -->
<section class="st-slider-tabs">
<h1>Sticky Nav Sliding Effects</h1>
<h3>Content Sliding with Sticky Tab Nav</h3>
<div class="st-slider-tabs-container">
<a class="st-slider-tab" href="#tab-tab1">Tab 1</a>
<a class="st-slider-tab" href="#tab-tab2">Tab 2</a>
<a class="st-slider-tab" href="#tab-tab3">Tab 3</a>
<a class="st-slider-tab" href="#tab-tab4">Tab 4</a>
<a class="st-slider-tab" href="#tab-tab5">Tab 5</a>
<span class="st-slider-tab-slider"></span>
</div>
</section>
<!-- Sliding Contents -->
<main class="st-main">
<section class="st-slide" id="tab-tab1">
<h1>Tab 1</h1>
<h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</h3>
</section>
<section class="st-slide" id="tab-tab2">
<h1>Tab 2</h1>
<h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</h3>
</section>
<section class="st-slide" id="tab-tab3">
<h1>Tab 3</h1>
<h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</h3>
</section>
<section class="st-slide" id="tab-tab4">
<h1>Tab 4</h1>
<h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</h3>
</section>
<section class="st-slide" id="tab-tab5">
<h1>Tab 5</h1>
<h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</h3>
</section>
</main>
Step 2 – Add CSS
Copy and paste below code in your HTML editor between <style></style> tag as below.
<style>
a {
text-decoration: none;
}
.st-slider-tabs,
.st-slide {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 34vh;
position: relative;
background-color: #68ffe4;
text-align: center;
padding: 0 2em;
}
.st-slide {
height: 75vh;
/* height: 100vh; */
}
.st-slider-tabs h1,
.st-slide h1 {
font-size: 2rem;
margin: 0;
letter-spacing: 1rem;
}
.st-slider-tabs h3,
.st-slide h3 {
font-size: 1rem;
letter-spacing: 0.3rem;
opacity: 0.6;
}
.st-slider-tabs-container {
display: flex;
flex-direction: row;
position: absolute;
bottom: 0;
width: 100%;
height: 70px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
background: #fff;
z-index: 10;
}
.st-slider-tabs-container--top {
position: fixed;
top: 0;
}
.st-slider-tab {
display: flex;
justify-content: center;
align-items: center;
flex: 1;
color: #000;
letter-spacing: 0.1rem;
transition: all 0.5s ease;
font-size: 0.8rem;
}
.st-slider-tab:hover {
color: white;
background: rgba(102, 177, 241, 0.8);
transition: all 0.5s ease;
}
.st-slider-tab-slider {
position: absolute;
bottom: 0;
width: 0;
height: 6px;
background: #66B1F1;
transition: left 0.3s ease;
}
@media (min-width: 800px) {
.st-slider-tabs h1,
.st-slide h1 {
font-size: 3rem;
}
.st-slider-tabs h3,
.st-slide h3 {
font-size: 1rem;
}
.st-slider-tab {
font-size: 1rem;
}
}
</style>
At the end we will have something like this. You can change fonts, colors, backgrounds and all things that you want. Enjoy it.
Step 3 – Add JavaScript
Copy and paste below code in your HTML editor between <script></script> tag.
<script>
class StickyNavigation {
constructor() {
this.currentId = null;
this.currentTab = null;
this.tabContainerHeight = 70;
let self = this;
$(".st-slider-tab").click(function() {
self.onTabClick(event, $(this));
});
$(window).scroll(() => {
this.onScroll();
});
$(window).resize(() => {
this.onResize();
});
}
onTabClick(event, element) {
event.preventDefault();
let scrollTop =
$(element.attr("href")).offset().top - this.tabContainerHeight + 1;
$("html, body").animate({
scrollTop: scrollTop
}, 600);
}
onScroll() {
this.checkTabContainerPosition();
this.findCurrentTabSelector();
}
onResize() {
if (this.currentId) {
this.setSliderCss();
}
}
checkTabContainerPosition() {
let offset =
$(".st-slider-tabs").offset().top +
$(".st-slider-tabs").height() -
this.tabContainerHeight;
if ($(window).scrollTop() > offset) {
$(".st-slider-tabs-container").addClass("st-slider-tabs-container--top");
} else {
$(".st-slider-tabs-container").removeClass("st-slider-tabs-container--top");
}
}
findCurrentTabSelector(element) {
let newCurrentId;
let newCurrentTab;
let self = this;
$(".st-slider-tab").each(function() {
let id = $(this).attr("href");
let offsetTop = $(id).offset().top - self.tabContainerHeight;
let offsetBottom =
$(id).offset().top + $(id).height() - self.tabContainerHeight;
if (
$(window).scrollTop() > offsetTop &&
$(window).scrollTop() < offsetBottom
) {
newCurrentId = id;
newCurrentTab = $(this);
}
});
if (this.currentId != newCurrentId || this.currentId === null) {
this.currentId = newCurrentId;
this.currentTab = newCurrentTab;
this.setSliderCss();
}
}
setSliderCss() {
let width = 0;
let left = 0;
if (this.currentTab) {
width = this.currentTab.css("width");
left = this.currentTab.offset().left;
}
$(".st-slider-tab-slider").css("width", width);
$(".st-slider-tab-slider").css("left", left);
}
}
new StickyNavigation();
</script>
Out Put


Video Tutorial
Please watch this video to better understand this tutorial and don’t forget to subscribe to our channel.
Help others to find out about this article on Social Media sites. If you have any doubt or any problem, don’t hesitate to contact us. Thereafter we will be able to help you and also make sure you bookmark our site on your browser.