A Pen by Nenad Kaevik on CodePen.
Created
July 10, 2018 11:41
-
-
Save CodeMyUI/1d243fd356472744443f056d25ca4d9d to your computer and use it in GitHub Desktop.
Elastic Tabs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="wrapper"> | |
<h2>Elastic Tabs</h2> | |
<h6>Click on tabs to see them in action</h6> | |
<nav class="tabs"> | |
<div class="selector"></div> | |
<a href="#" class="active"><i class="fas fa-burn"></i>Avengers</a> | |
<a href="#"><i class="fas fa-bomb"></i>Guardians of The Galaxy</a> | |
<a href="#"><i class="fas fa-bolt"></i>Thor</a> | |
<a href="#"><i class="fab fa-superpowers"></i>Black Panther</a> | |
</nav> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tabs = $('.tabs'); | |
var items = $('.tabs').find('a').length; | |
var selector = $(".tabs").find(".selector"); | |
var activeItem = tabs.find('.active'); | |
var activeWidth = activeItem.innerWidth(); | |
$(".selector").css({ | |
"left": activeItem.position.left + "px", | |
"width": activeWidth + "px" | |
}); | |
$(".tabs").on("click","a",function(){ | |
$('.tabs a').removeClass("active"); | |
$(this).addClass('active'); | |
var activeWidth = $(this).innerWidth(); | |
var itemPos = $(this).position(); | |
$(".selector").css({ | |
"left":itemPos.left + "px", | |
"width": activeWidth + "px" | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url('https://fonts.googleapis.com/css?family=Roboto'); | |
body{ | |
font-family: 'Roboto', sans-serif; | |
} | |
h2{ | |
margin:0px; | |
text-transform: uppercase; | |
} | |
h6{ | |
margin:0px; | |
color:#777; | |
} | |
.wrapper{ | |
text-align:center; | |
margin:50px auto; | |
} | |
.tabs{ | |
margin-top:50px; | |
font-size:15px; | |
padding:0px; | |
list-style:none; | |
background:#fff; | |
box-shadow:0px 5px 20px rgba(0,0,0,0.1); | |
display:inline-block; | |
border-radius:50px; | |
position:relative; | |
} | |
.tabs a{ | |
text-decoration:none; | |
color: #777; | |
text-transform:uppercase; | |
padding:10px 20px; | |
display:inline-block; | |
position:relative; | |
z-index:1; | |
transition-duration:0.6s; | |
} | |
.tabs a.active{ | |
color:#fff; | |
} | |
.tabs a i{ | |
margin-right:5px; | |
} | |
.tabs .selector{ | |
height:100%; | |
display:inline-block; | |
position:absolute; | |
left:0px; | |
top:0px; | |
z-index:1; | |
border-radius:50px; | |
transition-duration:0.6s; | |
transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55); | |
background: #05abe0; | |
background: -moz-linear-gradient(45deg, #05abe0 0%, #8200f4 100%); | |
background: -webkit-linear-gradient(45deg, #05abe0 0%,#8200f4 100%); | |
background: linear-gradient(45deg, #05abe0 0%,#8200f4 100%); | |
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#05abe0', endColorstr='#8200f4',GradientType=1 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" rel="stylesheet" /> |
l'animation + les liens ça ne marche pas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
j'ai repris le code mais les liens du menu ne fonctionne pas
que faire ????
merci d'avance