- Tab 1
- Tab 2
- Tab 3
Good morning. This is the content of Tab 1.
Hello. This is the content of Tab 2.
Good evening. This is the content of Tab 3.
HTML
<div class="container">
<h1>Tab Design 10 - Retro Gaming</h1>
<div class="tab-container">
<ul>
<li class="selected" data-id="tab-1">Tab 1</li>
<li data-id="tab-2">Tab 2</li>
<li data-id="tab-3">Tab 3</li>
</ul>
<div class="tab-content selected" id="tab-1">
Good morning. This is the content of Tab 1.
</div>
<div class="tab-content" id="tab-2">
Hello. This is the content of Tab 2.
</div>
<div class="tab-content" id="tab-3">
Good evening. This is the content of Tab 3.
</div>
</div>
</div>
CSS
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: #0a0a0a;
padding: 20px;
min-height: 100vh;
position: relative;
}
body::before {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background:
repeating-linear-gradient(
0deg,
transparent,
transparent 2px,
rgba(0, 255, 0, 0.02) 2px,
rgba(0, 255, 0, 0.02) 4px
);
pointer-events: none;
z-index: -1;
}
.container {
max-width: 800px;
margin: 0 auto;
background: #000;
border: 3px solid #00ff00;
border-radius: 8px;
box-shadow:
0 0 30px rgba(0, 255, 0, 0.5),
inset 0 0 30px rgba(0, 255, 0, 0.1);
overflow: hidden;
position: relative;
}
.container::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background:
repeating-linear-gradient(
0deg,
transparent,
transparent 2px,
rgba(0, 255, 0, 0.03) 2px,
rgba(0, 255, 0, 0.03) 4px
);
pointer-events: none;
z-index: 1;
}
h1 {
text-align: center;
padding: 30px 20px;
background: #000;
color: #00ff00;
margin: 0;
border-bottom: 2px solid #00ff00;
font-family: 'Orbitron', 'Courier New', 'Courier', monospace;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 2px;
text-shadow: 0 0 10px rgba(0, 255, 0, 0.8);
position: relative;
z-index: 2;
}
h1::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 1px;
background: linear-gradient(90deg,
transparent 0%,
#00ff00 50%,
transparent 100%);
animation: scanLine 2s linear infinite;
}
@keyframes scanLine {
0% { transform: translateX(-100%); }
100% { transform: translateX(100%); }
}
/* ===== Design 10: Retro Gaming ===== */
.tab-container {
overflow: hidden;
border-radius: 8px;
position: relative;
background: #0a0a0a;
border: 3px solid #00ff00;
box-shadow:
0 0 20px rgba(0, 255, 0, 0.5),
inset 0 0 20px rgba(0, 255, 0, 0.1);
z-index: 2;
}
.tab-container::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background:
repeating-linear-gradient(
0deg,
transparent,
transparent 2px,
rgba(0, 255, 0, 0.03) 2px,
rgba(0, 255, 0, 0.03) 4px
);
pointer-events: none;
z-index: 1;
}
.tab-container ul {
margin: 0;
padding: 0;
list-style: none;
display: flex;
background: #000;
border-bottom: 2px solid #00ff00;
position: relative;
z-index: 2;
}
.tab-container ul::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 1px;
background: linear-gradient(90deg,
transparent 0%,
#00ff00 50%,
transparent 100%);
animation: scanLine 2s linear infinite;
}
.tab-container ul li {
flex: 1;
padding: 16px 20px;
text-align: center;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
color: #00ff00;
font-family: 'Orbitron', 'Courier New', 'Courier', monospace;
font-weight: 700;
font-size: 14px;
text-transform: uppercase;
letter-spacing: 1px;
border-right: 1px solid #00ff00;
background: #000;
overflow: hidden;
}
.tab-container ul li:last-child {
border-right: none;
}
.tab-container ul li::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg,
transparent 0%,
rgba(0, 255, 0, 0.2) 50%,
transparent 100%);
transition: left 0.5s ease;
}
.tab-container ul li:hover::before {
left: 100%;
}
.tab-container ul li.selected {
color: #000;
background: #00ff00;
box-shadow:
0 0 15px rgba(0, 255, 0, 0.8),
inset 0 0 10px rgba(0, 0, 0, 0.3);
text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
animation: selectedPulse 1.5s ease-in-out infinite alternate;
}
@keyframes selectedPulse {
from {
box-shadow:
0 0 15px rgba(0, 255, 0, 0.8),
inset 0 0 10px rgba(0, 0, 0, 0.3);
}
to {
box-shadow:
0 0 25px rgba(0, 255, 0, 1),
inset 0 0 10px rgba(0, 0, 0, 0.3);
}
}
.tab-container ul li.selected::after {
content: '';
position: absolute;
bottom: -2px;
left: 0;
right: 0;
height: 2px;
background: #00ff00;
box-shadow: 0 0 10px rgba(0, 255, 0, 0.8);
}
.tab-container ul li:not(.selected):hover {
background: rgba(0, 255, 0, 0.1);
color: #00ff00;
text-shadow: 0 0 8px rgba(0, 255, 0, 0.8);
transform: translateY(-1px);
}
.tab-container .tab-content {
display: none;
padding: 24px;
min-height: 150px;
background: #000;
color: #00ff00;
font-family: 'Orbitron', 'Courier New', 'Courier', monospace;
font-size: 14px;
line-height: 1.6;
position: relative;
z-index: 2;
border: 1px solid #00ff00;
border-top: none;
}
.tab-container .tab-content::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 1px;
background: linear-gradient(90deg,
transparent 0%,
#00ff00 50%,
transparent 100%);
animation: scanLine 3s linear infinite;
}
.tab-container .tab-content::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background:
repeating-linear-gradient(
90deg,
transparent,
transparent 2px,
rgba(0, 255, 0, 0.02) 2px,
rgba(0, 255, 0, 0.02) 4px
);
pointer-events: none;
}
.tab-container .tab-content.selected {
display: block;
animation: retroFadeIn 0.4s ease;
}
@keyframes retroFadeIn {
from {
opacity: 0;
transform: translateY(-10px);
filter: blur(2px);
}
to {
opacity: 1;
transform: translateY(0);
filter: blur(0);
}
}
/* レトロゲーミング風のタイピングエフェクト */
.tab-container .tab-content.selected::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(90deg,
transparent 0%,
rgba(0, 255, 0, 0.1) 50%,
transparent 100%);
animation: typingEffect 2s ease-in-out infinite;
}
@keyframes typingEffect {
0%, 100% { opacity: 0; }
50% { opacity: 1; }
}
JavaScript
// Get tab container
const tabContainer = document.querySelector('.tab-container');
const tabMenuItems = tabContainer.querySelectorAll('ul li');
const tabContents = tabContainer.querySelectorAll('.tab-content');
// Set event listeners for each tab menu item
tabMenuItems.forEach(tabMenuItem => {
tabMenuItem.addEventListener('click', () => {
// Remove selected class from all tabs
tabMenuItems.forEach(item => {
item.classList.remove('selected');
});
// Add selected class only to clicked tab
tabMenuItem.classList.add('selected');
// Remove selected class from all tab contents
tabContents.forEach(tabContent => {
tabContent.classList.remove('selected');
});
// Add selected class to content with same ID as clicked tab's data attribute
document.getElementById(tabMenuItem.dataset.id).classList.add('selected');
});
});