Advertisement
Guest User

ktommy tabs

a guest
Jan 26th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. <style>
  2. body {font-family: Arial;}
  3.  
  4. /* Style the tab */
  5. .tab {
  6. overflow: hidden;
  7. border: 1px solid #ccc;
  8. background-color: #f1f1f1;
  9. }
  10.  
  11. /* Style the buttons inside the tab */
  12. .tab button {
  13. background-color: inherit;
  14. float: left;
  15. border: none;
  16. outline: none;
  17. cursor: pointer;
  18. padding: 14px 16px;
  19. transition: 0.3s;
  20. font-size: 17px;
  21. }
  22.  
  23. /* Change background color of buttons on hover */
  24. .tab button:hover {
  25. background-color: #ddd;
  26. }
  27.  
  28. /* Create an active/current tablink class */
  29. .tab button.active {
  30. background-color: #ccc;
  31. }
  32.  
  33. /* Style the tab content */
  34. .tabcontent {
  35. display: none;
  36. padding: 6px 12px;
  37. border: 1px solid #ccc;
  38. border-top: none;
  39. }
  40. </style>
  41. </head>
  42. <body>
  43.  
  44. <h2>Tabs by KTommy for Oat Chats</h2>
  45. <p>Click on the buttons inside the tabbed menu:</p>
  46.  
  47. <div class="tab">
  48. <button class="tablinks" onclick="openCity(event, 'London')">London</button>
  49. <button class="tablinks" onclick="openCity(event, 'Paris')">Paris</button>
  50. <button class="tablinks" onclick="openCity(event, 'Tokyo')">Tokyo</button>
  51. </div>
  52.  
  53. <div id="London" class="tabcontent">
  54. <h3>London</h3>
  55. <p>London is the capital city of England.</p>
  56. </div>
  57.  
  58. <div id="Paris" class="tabcontent">
  59. <h3>Paris</h3>
  60. <p>Paris is the capital of France.</p>
  61. </div>
  62.  
  63. <div id="Tokyo" class="tabcontent">
  64. <h3>Tokyo</h3>
  65. <p>Tokyo is the capital of Japan.</p>
  66. </div>
  67.  
  68. <script>
  69. function openCity(evt, cityName) {
  70. var i, tabcontent, tablinks;
  71. tabcontent = document.getElementsByClassName("tabcontent");
  72. for (i = 0; i < tabcontent.length; i++) {
  73. tabcontent[i].style.display = "none";
  74. }
  75. tablinks = document.getElementsByClassName("tablinks");
  76. for (i = 0; i < tablinks.length; i++) {
  77. tablinks[i].className = tablinks[i].className.replace(" active", "");
  78. }
  79. document.getElementById(cityName).style.display = "block";
  80. evt.currentTarget.className += " active";
  81. }
  82. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement