Jump to content

Coding

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 2402:8100:31dc:21f:4908:df32:a1a:3b1f (talk) at 08:44, 23 March 2025. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

<!DOCTYPE html> <html lang="en"> <head>

 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>Tabs Game</title>
 <link rel="stylesheet" href="styles.css">

</head> <body>

Tab 1
Tab 2
Tab 3

Welcome to Tab 1

This is the first tab where you can start the game.

   <button onclick="startGame()">Start Game</button>

Tab 2 - Game Progress

Your current progress is displayed here.

Tab 3 - Settings

Here you can adjust the game settings.

 <script src="script.js"></script>

</body> </html>

  • {
 margin: 0;
 padding: 0;
 box-sizing: border-box;

}

body {

 font-family: Arial, sans-serif;
 padding: 20px;

}

.tabs {

 display: flex;
 margin-bottom: 20px;

}

.tab {

 padding: 10px 20px;
 background-color: #f0f0f0;
 margin-right: 5px;
 cursor: pointer;

}

.tab:hover {

 background-color: #ddd;

}

.tab-content {

 display: none;
 margin-top: 20px;

}

.tab-content h2 {

 margin-bottom: 10px;

}

.active {

 background-color: #ccc;

}

  1. tab1 {
 display: block;

}

function showTab(tabId) {

 // Hide all tab contents
 const tabContents = document.querySelectorAll('.tab-content');
 tabContents.forEach(content => content.style.display = 'none');
 // Remove active class from all tabs
 const tabs = document.querySelectorAll('.tab');
 tabs.forEach(tab => tab.classList.remove('active'));
 // Show selected tab content
 document.getElementById(tabId).style.display = 'block';
 // Add active class to the clicked tab
 const selectedTab = Array.from(tabs).find(tab => tab.textContent === tabId.replace('tab', 'Tab '));
 selectedTab.classList.add('active');

}

function startGame() {

 // Placeholder function to start the game
 alert("Game Started!");

}

Computer science

Other uses

See also