Ukazka kodu
* { margin: 0; padding: 0; box-sizing: border-box; border: red solid 0.3px; /* Debugging trik: vidíme hranice elementov */ }
HTML dáva webu význam, ale CSS mu dáva dušu. V tomto projekte nepoužívame žiadne frameworky (ako Bootstrap alebo Tailwind). Píšeme Custom CSS pre maximálnu kontrolu nad vizuálom a výkonom.
Nižšie analyzujeme kľúčové techniky použité pri tvorbe portfólia: od Bento Grid layoutu až po pokročilý Glassmorphism efekt.
Každý dobrý CSS súbor začína resetom. Prehliadače majú rôzne predvolené nastavenia, ktoré chceme zjednotiť.
* { margin: 0; padding: 0; box-sizing: border-box; border: red solid 0.3px; /* Debugging trik: vidíme hranice elementov */ }
Najdôležitejší riadok v CSS. Zabezpečuje, že padding a border nezväčšujú element nad rámec definovanej šírky. Bez tohto sa layouty ťažko počítajú.
Trik pokročilých vývojárov. Pridanie tenkého
červeného okraja na * nám umožní
okamžite vidieť, ako sú elementy poskladané a kde
nám preteká obsah.
Srdcom dizajnu je "Bento Grid" – modulárna mriežka inšpirovaná japonskými boxmi na obed. Používame CSS Grid s 12 stĺpcami pre maximálnu flexibilitu.
.bento-grid { display: grid; grid-template-columns: repeat(12, 1fr); /* 12 flexibilných stĺpcov */ gap: 1.5rem; margin-bottom: 1.5rem; } #hero { grid-column: span 6; /* Zaberá polovicu (6/12) */ min-height: 500px; } article { grid-column: span 4; /* Zaberá tretinu (4/12) */ }
Pre tlačidlá sme použili moderný "frosted glass" efekt. Toto je najkomplexnejšia časť CSS, ktorá využíva vrstvenie tieňov, priehľadnosti a filtrov.
.glass-button { background: linear-gradient(-75deg, rgba(255,255,255,0.08), rgba(255,255,255,0.08)); backdrop-filter: blur(4px); /* Rozmaže pozadie za tlačidlom */ border-radius: 999vw; /* Dokonalá pilulka */ box-shadow: inset 0 0.125em 0.125em rgba(255, 255, 255, 0.1), /* Vnútorný odlesk */ 0 0.25em 0.125em -0.125em rgba(0, 0, 0, 0.5); /* Vonkajší tieň */ }
Tu je kompletný stylesheet pre portfólio. Skopírujte tento
kód do súboru style/finalPage/style.css.
* { margin: 0; padding: 0; box-sizing: border-box; border: red solid 0.3px; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #0a0a0a; color: #e0e0e0; line-height: 1.6; } header { padding: 2rem 4rem; display: flex; justify-content: space-between; align-items: center; background: #0a0a0a; } .logo { font-size: 1.5rem; font-weight: bold; color: #fff; } nav ul { list-style: none; display: flex; gap: 2rem; margin: 0; padding: 0; align-items: center; } nav a { color: #999; text-decoration: none; font-size: 0.95rem; transition: color 0.3s; } nav a:hover { color: #fff; } main { max-width: 1400px; margin: 0 auto; padding: 2rem 4rem; } .bento-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1.5rem; margin-bottom: 1.5rem; } section { background: #1a1a1a; border-radius: 24px; padding: 2.5rem; border: 1px solid #2a2a2a; transition: transform 0.3s, border-color 0.3s; } section:hover { transform: translateY(-4px); border-color: #3a3a3a; } #hero { grid-column: span 6; display: flex; flex-direction: column; justify-content: space-between; min-height: 500px; } #hero-image { grid-column: span 6; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 24px; overflow: hidden; min-height: 500px; display: flex; align-items: center; justify-content: center; padding: 0; } #hero-image img { width: 100%; height: 100%; object-fit: cover; } figure { width: 80px; height: 80px; border-radius: 50%; border: 3px solid #667eea; margin-bottom: 2rem; overflow: hidden; } figure img { width: 100%; height: 100%; object-fit: cover; } #hero h1 { font-size: 3rem; color: #fff; margin-bottom: 1rem; line-height: 1.2; } #hero p { font-size: 1.1rem; color: #999; margin-bottom: 2rem; } .social-links { margin-top: 1rem; display: flex; gap: 3rem; } .glass-button { --border-width: clamp(1px, 0.0625em, 4px); --anim--hover-time: 0.3s; --anim--hover-ease: ease; all: unset; cursor: pointer; position: relative; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); pointer-events: auto; z-index: 3; background: linear-gradient(-75deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08)); border-radius: 999vw; box-shadow: inset 0 0.125em 0.125em rgba(255, 255, 255, 0.1), inset 0 -0.125em 0.125em rgba(0, 0, 0, 0.3), 0 0.25em 0.125em -0.125em rgba(0, 0, 0, 0.5), 0 0 0 1px inset rgba(255, 255, 255, 0.15), 0 0 1em 0 rgba(255, 255, 255, 0.05); backdrop-filter: blur(clamp(1px, 0.125em, 4px)); -webkit-backdrop-filter: blur(clamp(1px, 0.125em, 4px)); transition: all var(--anim--hover-time) var(--anim--hover-ease); padding: 1rem 2.5rem; font-size: 1rem; font-weight: 500; color: #ffffff; text-transform: uppercase; letter-spacing: 0.05em; display: inline-block; } .glass-button:hover { background: linear-gradient(-75deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.12)); transform: translateY(-2px); } .glass-button:active { transform: translateY(0); } .social-links a { padding: 10px; background: #2a2a2a; border-radius: 15px; display: flex; align-items: center; justify-content: center; color: #fff; text-decoration: none; font-size: 1.0rem; transition: background 0.3s, transform 0.3s; } .social-links a:hover { background: #667eea; transform: scale(1.1); } article { grid-column: span 4; min-height: 320px; display: flex; flex-direction: column; justify-content: space-between; } article header { padding: 0; background: none; display: block; } .project-icon { width: 60px; height: 60px; background: #2a2a2a; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 2rem; margin-bottom: 2rem; } article h3 { font-size: 1.5rem; color: #fff; margin-bottom: 1rem; } article p { color: #999; font-size: 0.95rem; line-height: 1.6; } #about { grid-column: span 8; min-height: 350px; } #about h2 { font-size: 2rem; color: #fff; margin-bottom: 1.5rem; } #about p { color: #999; font-size: 1.05rem; line-height: 1.8; margin-bottom: 1rem; } #about strong { color: #667eea; } #about em { color: #b8b8b8; font-style: normal; } #about mark { background: rgba(102, 126, 234, 0.2); color: #667eea; padding: 2px 6px; border-radius: 4px; } #contact { grid-column: span 4; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); text-align: center; display: flex; flex-direction: column; justify-content: center; min-height: 350px; } #contact h2 { font-size: 2rem; color: #fff; margin-bottom: 1rem; } #contact p { color: rgba(255, 255, 255, 0.9); margin-bottom: 2rem; font-size: 1.05rem; } #contact a { display: inline-block; padding: 1rem 2.5rem; background: #fff; color: #667eea; text-decoration: none; border-radius: 12px; font-weight: bold; transition: transform 0.3s, box-shadow 0.3s; } #contact a:hover { transform: scale(1.05); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); } #skills { grid-column: span 12; } #skills h2 { font-size: 2rem; color: #fff; margin-bottom: 2rem; text-align: center; } .skills-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 2rem; } .skill-category h3 { color: #667eea; margin-bottom: 1.5rem; font-size: 1.3rem; } .skill-category ul { list-style: none; } .skill-category li { padding: 0.8rem 0; border-bottom: 1px solid #2a2a2a; color: #999; font-size: 1.05rem; } .skill-category li:last-child { border-bottom: none; } footer { background: #0a0a0a; padding: 3rem 4rem; margin-top: 3rem; border-top: 1px solid #1a1a1a; display: flex; justify-content: space-between; align-items: center; max-width: 1400px; margin-left: auto; margin-right: auto; } footer p { color: #666; font-size: 0.95rem; } footer ul { display: flex; gap: 2rem; list-style: none; } footer a { color: #999; text-decoration: none; font-size: 0.95rem; transition: color 0.3s; } footer a:hover { color: #667eea; } @media (max-width: 968px) { header { padding: 1.5rem 2rem; flex-direction: column; gap: 1rem; } nav ul { gap: 1.5rem; } main { padding: 1.5rem 2rem; } #hero, #hero-image, #about, #contact, article, #skills { grid-column: span 12; } #hero h1 { font-size: 2rem; } footer { flex-direction: column; gap: 1.5rem; text-align: center; padding: 2rem; } }