Jasne, oto kompletny kod strony internetowej w jednym pliku index.html, spełniający wszystkie Twoje wymagania.
Kod jest gotowy do zapisania i otwarcia w dowolnej nowoczesnej przeglądarce internetowej.
Jak użyć:
- Skopiuj cały poniższy kod.
- Wklej go do edytora tekstu (np. Notatnik, VS Code, Sublime Text).
- Zapisz plik pod nazwą
index.html.
- Otwórz plik
index.html w przeglądarce internetowej (np. Chrome, Firefox, Edge).
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kodowanie to pestka!</title>
<style>
/* --- GLOBALNE STYLE I RESET --- */
:root {
--header-bg: #A98FFD;
--section2-bg: #FFFFE0; /* Jasnożółty */
--section3-bg: #FFCCCB; /* Jasnoczerwony */
--text-color: #000000;
--content-width: 70%;
--margin-width: 15%;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
scroll-behavior: smooth;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
color: var(--text-color);
background-color: var(--header-bg); /* Tło body na wypadek opóźnień w ładowaniu */
}
/* --- GŁÓWNY KONTENER TREŚCI --- */
.content-container {
width: var(--content-width);
margin: 0 var(--margin-width);
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
/* --- SEKCJE NA PEŁNĄ WYSOKOŚĆ --- */
.full-height-section {
min-height: 100vh; /* Używamy min-height zamiast height dla lepszej kompatybilności */
width: 100%;
display: flex;
align-items: center;
padding: 60px 0; /* Padding na wypadek małych ekranów */
}
#header-section { background-color: var(--header-bg); }
#section-2 { background-color: var(--section2-bg); }
#section-3 { background-color: var(--section3-bg); }
/* --- STYLOWANIE SEKCJI HEADER --- */
#header-section .content-container {
display: flex;
gap: 2rem;
align-items: center;
}
.header-text {
flex: 1;
animation: fadeInText 1s ease-in-out;
}
.header-text h1 {
font-size: 5vw; /* Skalowalny duży nagłówek */
font-weight: 800;
line-height: 1.1;
margin-bottom: 1rem;
}
.header-text p {
font-size: 1.5vw; /* Skalowalny mniejszy tekst */
font-weight: 400;
}
.header-image {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
animation: fadeInImage 1s 0.5s ease-in-out backwards; /* Opóźniona animacja */
}
.header-image img {
max-width: 100%;
height: auto;
max-height: 70vh;
}
@keyframes fadeInText {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInImage {
from { opacity: 0; transform: scale(0.9); }
to { opacity: 1; transform: scale(1); }
}
/* --- STYLOWANIE SEKCJI 2 i 3 --- */
#section-2 .content-container,
#section-3 .content-container {
font-size: 2rem;
font-weight: bold;
text-align: center;
}
/* --- NAVBAR --- */
.navbar {
position: fixed;
top: 20px;
left: 50%;
transform: translateX(-50%);
width: 60%; /* Węższy niż treść */
padding: 12px 30px;
border-radius: 50px; /* Zaokrąglone końcówki */
z-index: 1000;
display: flex;
justify-content: space-between;
align-items: center;
transition: top 0.3s;
/* Efekt "szkła" (glassmorphism) */
background: rgba(255, 255, 255, 0.25);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px); /* Dla Safari */
border: 1px solid rgba(255, 255, 255, 0.18);
}
.nav-links {
display: flex;
align-items: center;
gap: 25px;
list-style: none;
}
.nav-links a, .nav-links .search-icon-container {
text-decoration: none;
color: var(--text-color);
font-weight: 500;
padding: 5px 10px;
border-radius: 8px;
transition: background-color 0.3s;
}
.nav-links a:hover {
background-color: rgba(255, 255, 255, 0.2);
}
.search-icon-container {
background-color: rgba(0, 0, 0, 0.1);
cursor: pointer;
padding: 8px 10px;
border-radius: 12px;
display: flex;
align-items: center;
}
.search-icon-container svg {
width: 20px;
height: 20px;
}
/* --- WYSZUKIWARKA MODALNA --- */
.search-overlay {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 1999;
display: none; /* Domyślnie ukryte */
}
.search-container {
position: fixed;
top: 25%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2000;
display: none; /* Domyślnie ukryte */
opacity: 0;
transition: opacity 0.3s ease-in-out, top 0.3s ease-in-out;
}
.search-container.active {
display: block;
top: 30%;
opacity: 1;
}
#search-input {
width: 50vw;
max-width: 600px;
padding: 20px 30px;
font-size: 1.5rem;
border: none;
border-radius: 50px;
outline: none;
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
/* Efekt rozmycia strony pod wyszukiwarką */
body.search-active main,
body.search-active .navbar {
filter: blur(8px);
transition: filter 0.3s ease-in-out;
}
/* --- RESPONSIVE DESIGN --- */
/* Ukrycie elementów mobilnych na desktopie */
.mobile-menu-toggle, .mobile-nav-menu {
display: none;
}
/* Widok mobilny - breakpoint 992px */
@media (max-width: 992px) {
:root {
--content-width: 85%;
--margin-width: 7.5%;
}
.header-text h1 { font-size: 7vw; }
.header-text p { font-size: 2.5vw; }
.navbar { width: 90%; }
}
/* Widok mobilny - breakpoint 768px */
@media (max-width: 768px) {
/* Zmiana layoutu nagłówka na kolumnowy */
#header-section .content-container {
flex-direction: column;
text-align: center;
gap: 3rem;
padding-top: 100px; /* Dodatkowy padding, by nie nachodził na navbar */
}
.header-text h1 { font-size: 10vw; }
.header-text p { font-size: 4vw; }
.header-image img { max-height: 40vh; }
/* Zmiana Navbara na mobilny */
.nav-links {
display: none; /* Ukryj linki desktopowe */
}
.navbar {
justify-content: space-between;
}
/* Przycisk "Index" po lewej stronie */
.navbar-brand {
display: block;
font-weight: 700;
font-size: 1.2rem;
color: var(--text-color);
}
/* Przycisk hamburgera */
.mobile-menu-toggle {
display: flex;
flex-direction: column;
justify-content: space-around;
width: 30px;
height: 25px;
background: transparent;
border: none;
cursor: pointer;
padding: 0;
z-index: 10;
}
.mobile-menu-toggle .bar {
width: 30px;
height: 3px;
background-color: var(--text-color);
border-radius: 10px;
transition: all 0.3s linear;
position: relative;
transform-origin: 1px;
}
/* Menu mobilne (overlay) */
.mobile-nav-menu {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(15px);
-webkit-backdrop-filter: blur(15px);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
transform: translateX(100%);
transition: transform 0.3s ease-in-out;
}
.mobile-nav-menu.active {
transform: translateX(0);
}
.mobile-nav-menu ul {
list-style: none;
padding: 0;
text-align: center;
}
.mobile-nav-menu li {
margin: 20px 0;
}
.mobile-nav-menu a {
text-decoration: none;
color: var(--text-color);
font-size: 2rem;
font-weight: bold;
}
/* Animacja przycisku hamburgera do "X" */
.mobile-menu-toggle.active .bar:nth-child(1) {
transform: rotate(45deg);
}
.mobile-menu-toggle.active .bar:nth-child(2) {
opacity: 0;
transform: translateX(20px);
}
.mobile-menu-toggle.active .bar:nth-child(3) {
transform: rotate(-45deg);
}
}
</style>
</head>
<body>
<!-- NAVBAR -->
<nav class="navbar">
<!-- Brand/Logo widoczny tylko na mobile -->
<div class="navbar-brand">Index</div>
<!-- Linki na Desktop -->
<ul class="nav-links">
<li><a href="#header-section">Index</a></li>
<li><a href="#">About</a></li>
<li class="search-icon-container" id="search-icon">
<!-- Ikona lupy jako SVG dla czystości kodu i skalowalności -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"/>
</svg>
</li>
<li><a href="#">Pricing</a></li>
<li><a href="#">Contact</a></li>
</ul>
<!-- Przycisk menu mobilnego (hamburger) -->
<button class="mobile-menu-toggle" id="mobile-menu-toggle">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</button>
</nav>
<!-- MENU MOBILNE (domyślnie ukryte) -->
<div class="mobile-nav-menu" id="mobile-nav-menu">
<ul>
<li><a href="#header-section">Index</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Pricing</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<!-- WYSZUKIWARKA MODALNA (domyślnie ukryta) -->
<div class="search-overlay" id="search-overlay"></div>
<div class="search-container" id="search-container">
<input type="text" id="search-input" placeholder="Wpisz szukaną frazę...">
</div>
<!-- GŁÓWNA TREŚĆ STRONY -->
<main>
<!-- SEKCJA 1: HEADER -->
<section id="header-section" class="full-height-section">
<div class="content-container">
<div class="header-text">
<h1>Kodowanie to dla mnie pestka</h1>
<p>Stworzę dla ciebie najlepszą stronę WWW!</p>
</div>
<div class="header-image">
<!-- Ilustracja z serwisu unDraw.co - darmowa, z przezroczystością -->
<img src="https://ik.imagekit.io/sif752kdn/undraw_developer_activity_re_3wem_LS8Hq51nB.png?updatedAt=1711204646045" alt="Ilustracja programisty przy biurku">
</div>
</div>
</section>
<!-- SEKCJA 2 -->
<section id="section-2" class="full-height-section">
<div class="content-container">
<p>Lorem Ipsum</p>
</div>
</section>
<!-- SEKCJA 3 -->
<section id="section-3" class="full-height-section">
<div class="content-container">
<p>Lorem Ipsum</p>
</div>
</section>
</main>
<script>
document.addEventListener('DOMContentLoaded', function() {
// --- OBSŁUGA WYSZUKIWARKI ---
const searchIcon = document.getElementById('search-icon');
const searchContainer = document.getElementById('search-container');
const searchOverlay = document.getElementById('search-overlay');
const searchInput = document.getElementById('search-input');
const body = document.body;
// Otwieranie wyszukiwarki po kliknięciu ikony
searchIcon.addEventListener('click', function(event) {
event.stopPropagation(); // Zapobiega natychmiastowemu zamknięciu
body.classList.add('search-active');
searchOverlay.style.display = 'block';
searchContainer.classList.add('active');
// Ustawienie fokusu na polu input, aby można było od razu pisać
// Używamy setTimeout, aby dać przeglądarce czas na wyświetlenie elementu
setTimeout(() => {
searchInput.focus();
}, 100);
});
// Zamykanie wyszukiwarki po kliknięciu poza nią (na overlay)
searchOverlay.addEventListener('click', function() {
body.classList.remove('search-active');
searchContainer.classList.remove('active');
// Czekamy na zakończenie animacji zanikania przed ukryciem elementu
setTimeout(() => {
searchOverlay.style.display = 'none';
}, 300);
});
// Zapobieganie zamknięciu po kliknięciu wewnątrz pola wyszukiwania
searchContainer.addEventListener('click', function(event) {
event.stopPropagation();
});
// --- OBSŁUGA MENU MOBILNEGO ---
const mobileMenuToggle = document.getElementById('mobile-menu-toggle');
const mobileNavMenu = document.getElementById('mobile-nav-menu');
mobileMenuToggle.addEventListener('click', function() {
mobileMenuToggle.classList.toggle('active');
mobileNavMenu.classList.toggle('active');
});
// Zamykanie menu mobilnego po kliknięciu w link
const mobileLinks = document.querySelectorAll('.mobile-nav-menu a');
mobileLinks.forEach(link => {
link.addEventListener('click', () => {
mobileMenuToggle.classList.remove('active');
mobileNavMenu.classList.remove('active');
});
});
});
</script>
</body>
</html>