Advertisement
ssaidz

Create Animated Tab Content ( CSS JS)

Aug 26th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <meta name="viewport" content="width=device-width, initial-scale=1">
  4. <link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
  5. <style>
  6. .city {display:none;}
  7. </style>
  8. <body>
  9.  
  10. <nav class="w3-sidenav w3-black w3-card-2" style="width:130px">
  11.   <div class="w3-container">
  12.     <h5>Menu</h5>
  13.   </div>
  14.   <a href="#" class="tablink" onclick="openCity(event, 'London')">London</a>
  15.   <a href="#" class="tablink" onclick="openCity(event, 'Paris')">Paris</a>
  16.   <a href="#" class="tablink" onclick="openCity(event, 'Tokyo')">Tokyo</a>
  17. </nav>
  18.  
  19. <div style="margin-left:130px">
  20.   <div class="w3-padding">Use any of the w3-animate-classes to fade, zoom or slide in tab content. Click on the links.</div>
  21.  
  22.   <div id="London" class="w3-container city w3-animate-left">
  23.     <h2>London</h2>
  24.     <p>London is the capital city of England.</p>
  25.     <p>It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
  26.   </div>
  27.  
  28.   <div id="Paris" class="w3-container city w3-animate-opacity">
  29.     <h2>Paris</h2>
  30.     <p>Paris is the capital of France.</p>
  31.     <p>The Paris area is one of the largest population centers in Europe, with more than 12 million inhabitants.</p>
  32.   </div>
  33.  
  34.   <div id="Tokyo" class="w3-container city w3-animate-zoom">
  35.     <h2>Tokyo</h2>
  36.     <p>Tokyo is the capital of Japan.</p>
  37.     <p>It is the center of the Greater Tokyo Area, and the most populous metropolitan area in the world.</p>
  38.   </div>
  39.  
  40. </div>
  41.  
  42. <script>
  43. function openCity(evt, cityName) {
  44.   var i, x, tablinks;
  45.   x = document.getElementsByClassName("city");
  46.   for (i = 0; i < x.length; i++) {
  47.      x[i].style.display = "none";
  48.   }
  49.   tablinks = document.getElementsByClassName("tablink");
  50.   for (i = 0; i < x.length; i++) {
  51.      tablinks[i].className = tablinks[i].className.replace(" w3-red", "");
  52.   }
  53.   document.getElementById(cityName).style.display = "block";
  54.   evt.currentTarget.className += " w3-red";
  55. }
  56. </script>
  57.  
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement