아래는 모든 HTML, CSS, JavaScript 코드가 한 파일에 포함된, 고급 인터랙션, 애니메이션, 패럴랙스 스크롤, 창의적인 인터랙션 효과 등을 구현한 포트폴리오 웹사이트 예제입니다.
이 코드는 브라우저에서 바로 실행할 수 있으며, 실제 동작 시연을 위해 다양한 애니메이션, 패럴랙스 효과, Canvas 기반의 파티클 배경, 스크롤 인디케이터, 인터랙티브한 섹션 애니메이션 등을 포함하고 있습니다.
주의:
- 외부 이미지나 글꼴은 공개 CDN을 사용하거나 여러분의 환경에 맞게 수정해 주세요.
- 리소스(예, 고해상도 이미지)의 경우 인터넷 연결이 필요할 수 있습니다.
- 코드는 예제이므로 실제 사용 시 세부 디자인, 접근성, 모바일 대응 등을 추가 검토하시기 바랍니다.
아래 코드를 복사하여 HTML 파일로 저장한 후 브라우저에서 실행해 보세요.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Creative Portfolio</title>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;500;700&family=Open+Sans:wght@300;400;600&display=swap" rel="stylesheet">
<style>
/* 기본 리셋 및 폰트 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
font-family: 'Open Sans', sans-serif;
overflow-x: hidden;
scroll-behavior: smooth;
}
a {
text-decoration: none;
color: inherit;
}
/* 네비게이션 */
header {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 1000;
background: rgba(0,0,0,0.7);
padding: 10px 50px;
display: flex;
align-items: center;
justify-content: space-between;
}
header nav ul {
display: flex;
list-style: none;
}
header nav ul li {
margin: 0 15px;
position: relative;
overflow: hidden;
}
header nav ul li a {
color: #fff;
font-weight: 600;
padding: 5px 0;
position: relative;
transition: color 0.3s ease;
}
header nav ul li a:hover {
color: #efefef;
}
/* 애니메이션되는 언더라인 효과 */
header nav ul li a::after {
content: '';
position: absolute;
left: 0;
bottom: -2px;
width: 100%;
height: 2px;
background: #fff;
transform: translateX(-100%);
transition: transform 0.3s ease;
}
header nav ul li a:hover::after {
transform: translateX(0);
}
/* Hero Section (패럴랙스 및 파티클 배경) */
#hero {
position: relative;
height: 100vh;
overflow: hidden;
background-image: url('https://images.unsplash.com/photo-1507525428034-b723cf961d3e?auto=format&fit=crop&w=1950&q=80');
background-size: cover;
background-attachment: fixed;
background-position: center;
}
#hero::before {
position: absolute;
content: '';
top: 0;
left: 0;
height: 100%;
width: 100%;
background: rgba(0,0,0,0.5);
z-index: 1;
}
/* 캔버스 파티클 효과는 hero 내에 배치 */
#particle-canvas {
position: absolute;
top: 0;
left: 0;
z-index: 2;
}
.hero-content {
position: relative;
z-index: 3;
text-align: center;
top: 50%;
transform: translateY(-50%);
color: #fff;
width: 100%;
padding: 0 20px;
}
.hero-content h1 {
font-family: 'Montserrat', sans-serif;
font-size: 4rem;
margin-bottom: 20px;
letter-spacing: 2px;
opacity: 0;
transform: translateY(-50px);
animation: fadeInUp 1s forwards 0.5s;
}
.hero-content p {
font-size: 1.2rem;
line-height: 1.6;
max-width: 600px;
margin: 0 auto;
opacity: 0;
transform: translateY(50px);
animation: fadeInUp 1s forwards 1s;
}
@keyframes fadeInUp {
to {
opacity: 1;
transform: translateY(0);
}
}
/* Section 기본 스타일 */
section {
padding: 100px 50px;
position: relative;
}
/* 스크롤에 따라 나타나는 애니메이션 */
.animate {
opacity: 0;
transform: translateY(30px);
transition: all 0.8s ease-out;
}
.animate.active {
opacity: 1;
transform: translateY(0);
}
/* About 섹션 */
#about {
background: #f7f7f7;
}
#about h2 {
font-family: 'Montserrat', sans-serif;
text-align: center;
font-size: 2.5rem;
margin-bottom: 40px;
}
#about p {
max-width: 800px;
margin: 0 auto;
text-align: center;
line-height: 1.8;
color: #555;
font-size: 1.1rem;
}
/* Projects 섹션 */
#projects {
background: #fff;
}
#projects h2 {
font-family: 'Montserrat', sans-serif;
text-align: center;
font-size: 2.5rem;
margin-bottom: 40px;
}
.project-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 30px;
}
.project {
position: relative;
width: 300px;
height: 200px;
overflow: hidden;
border-radius: 8px;
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
cursor: pointer;
}
.project img {
width: 100%;
height: 100%;
object-fit: cover;
transform: scale(1);
transition: transform 0.5s ease;
}
.project:hover img {
transform: scale(1.1);
}
.project .overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.6);
opacity: 0;
transition: opacity 0.5s ease;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 1.2rem;
font-weight: 600;
}
.project:hover .overlay {
opacity: 1;
}
/* Contact 섹션 */
#contact {
background: #222;
color: #fff;
text-align: center;
}
#contact h2 {
font-family: 'Montserrat', sans-serif;
font-size: 2.5rem;
margin-bottom: 20px;
}
#contact p {
font-size: 1.1rem;
margin-bottom: 40px;
}
#contact form {
max-width: 500px;
margin: 0 auto;
display: flex;
flex-direction: column;
}
#contact form input,
#contact form textarea {
padding: 15px;
margin-bottom: 20px;
border: none;
border-radius: 4px;
outline: none;
font-size: 1rem;
}
#contact form button {
padding: 15px;
border: none;
border-radius: 4px;
background: #00aaff;
color: #fff;
font-size: 1rem;
cursor: pointer;
transition: background 0.3s ease;
}
#contact form button:hover {
background: #0088cc;
}
/* Footer */
footer {
background: #111;
color: #aaa;
text-align: center;
padding: 20px;
font-size: 0.9rem;
}
/* 반응형 */
@media(max-width: 768px) {
header {
padding: 10px 20px;
}
.hero-content h1 {
font-size: 2.5rem;
}
#about, #projects, #contact {
padding: 80px 20px;
}
.project {
width: 90%;
height: auto;
}
}
</style>
</head>
<body>
<!-- 네비게이션 -->
<header>
<div class="logo" style="color:#fff; font-size:1.5rem; font-weight:700;">MyPortfolio</div>
<nav>
<ul>
<li><a href="#hero">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#projects">Works</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<!-- Hero Section (패럴랙스, 분리된 캔버스 파티클 효과) -->
<section id="hero">
<canvas id="particle-canvas"></canvas>
<div class="hero-content">
<h1>Welcome to My Creative Portfolio</h1>
<p>세련된 디자인, 인터랙션, 애니메이션 효과로 구현한 나만의 디지털 작품 세계로 초대합니다.</p>
</div>
</section>
<!-- About Section -->
<section id="about">
<h2 class="animate">About Me</h2>
<p class="animate">
저는 UI/UX 디자이너이자 프론트엔드 개발자로, 최첨단 기술과 창의적인 아이디어를 결합하여 놀라운 사용자 경험을 만들어내고 있습니다.
최신 웹 트렌드와 인터랙션을 기반으로 한 제작물을 통해 비전문가들도 감탄할 만한 작품들을 선보입니다.
</p>
</section>
<!-- Projects Section -->
<section id="projects">
<h2 class="animate">My Works</h2>
<div class="project-container">
<div class="project animate">
<img src="https://images.unsplash.com/photo-1498050108023-c5249f4df085?auto=format&fit=crop&w=400&q=80" alt="Project 1">
<div class="overlay">Project 1</div>
</div>
<div class="project animate">
<img src="https://images.unsplash.com/photo-1517694712202-14dd9538aa97?auto=format&fit=crop&w=400&q=80" alt="Project 2">
<div class="overlay">Project 2</div>
</div>
<div class="project animate">
<img src="https://images.unsplash.com/photo-1533750349088-cd871a92f312?auto=format&fit=crop&w=400&q=80" alt="Project 3">
<div class="overlay">Project 3</div>
</div>
</div>
</section>
<!-- Contact Section -->
<section id="contact">
<h2 class="animate">Get in Touch</h2>
<p class="animate">궁금하신 내용이나 협업 문의는 아래 양식을 통해 문의해 주세요.</p>
<form class="animate">
<input type="text" placeholder="Your Name" required>
<input type="email" placeholder="Your Email" required>
<textarea rows="5" placeholder="Your Message" required></textarea>
<button type="submit">SEND MESSAGE</button>
</form>
</section>
<!-- Footer -->
<footer>
© 2023 MyPortfolio. All Rights Reserved.
</footer>
<!-- JavaScript -->
<script>
/* -------------------
Particles Animation
------------------- */
(function() {
const canvas = document.getElementById("particle-canvas");
const ctx = canvas.getContext("2d");
let width, height;
let particles = [];
const particleCount = 100;
function initCanvas() {
width = canvas.width = window.innerWidth;
height = canvas.height = document.getElementById("hero").offsetHeight;
}
window.addEventListener("resize", initCanvas);
initCanvas();
// Particle 클래스
class Particle {
constructor() {
this.reset();
}
reset() {
this.x = Math.random() * width;
this.y = Math.random() * height;
this.speedX = (Math.random() - 0.5) * 0.5;
this.speedY = (Math.random() - 0.5) * 0.5;
this.size = Math.random() * 2 + 1;
this.alpha = Math.random() * 0.5 + 0.5;
}
update() {
this.x += this.speedX;
this.y += this.speedY;
if (this.x < 0 || this.x > width || this.y < 0 || this.y > height) {
this.reset();
}
}
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fillStyle = "rgba(255,255,255," + this.alpha + ")";
ctx.fill();
}
}
// 초기 파티클 생성
for (let i = 0; i < particleCount; i++) {
particles.push(new Particle());
}
function animateParticles() {
ctx.clearRect(0, 0, width, height);
particles.forEach(p => {
p.update();
p.draw();
});
requestAnimationFrame(animateParticles);
}
animateParticles();
// 마우스 인터랙션: 근처로 모여드는 효과
canvas.addEventListener("mousemove", function(e) {
const rect = canvas.getBoundingClientRect();
const mouseX = e.clientX - rect.left;
const mouseY = e.clientY - rect.top;
particles.forEach(p => {
const dx = p.x - mouseX;
const dy = p.y - mouseY;
const dist = Math.sqrt(dx * dx + dy * dy);
if(dist < 80) {
p.x += dx * 0.03;
p.y += dy * 0.03;
}
});
});
})();
/* ------------------------
Intersection Observer
------------------------ */
(function() {
const animatedElems = document.querySelectorAll('.animate');
const observerOptions = {
threshold: 0.2
};
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if(entry.isIntersecting) {
entry.target.classList.add('active');
// 옵션: 한 번 보여진 요소는 관찰 해제 (애니메이션 반복 원하면 주석처리)
observer.unobserve(entry.target);
}
});
}, observerOptions);
animatedElems.forEach(elem => {
observer.observe(elem);
});
})();
/* ------------------------
Smooth Parallax Scrolling
------------------------ */
(function() {
// hero 배경의 패럴랙스 효과 (추가 보정)
const hero = document.getElementById("hero");
window.addEventListener("scroll", function() {
const scrolled = window.pageYOffset;
// 배경 이미지의 위치 변경
hero.style.backgroundPositionY = -(scrolled * 0.3) + "px";
});
})();
/* ------------------------
Navigation Smooth Scroll Enhancement
------------------------ */
(function() {
// 모든 내부 링크에 대해 부드러운 스크롤 효과를 강화
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener("click", function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute("href"));
if(target) {
target.scrollIntoView({
behavior: "smooth",
block: "start"
});
}
});
});
})();
</script>
</body>
</html>
코드 주요 기능 설명
-
네비게이션 인터랙션
- 헤더에는 호버 시 밑줄 애니메이션 효과가 적용되어 부드러운 색상 전환을 보여줍니다.
-
Hero 섹션
- 패럴랙스 배경: CSS의
background-attachment: fixed와 스크롤 이벤트를 활용하여 배경 이미지가 부드럽게 움직입니다.
- Canvas 파티클 배경: 캔버스를 이용하여 파티클 애니메이션을 구현하고, 마우스 움직임에 반응하는 인터랙션을 추가했습니다.
-
섹션 애니메이션
- 스크롤 시 Intersection Observer API를 이용하여 각 섹션 내 요소(
.animate 클래스)가 서서히 나타나는 애니메이션 효과를 보여줍니다.
-
프로젝트 섹션
- 프로젝트 이미지는 호버 시 줌 효과와 함께 오버레이가 나타나, 사용자에게 클릭 유도 효과를 줍니다.
-
Contact 섹션
- 심플하면서도 깔끔한 양식 디자인과 인터랙션 효과를 더해 사용자가 쉽게 메시지를 보낼 수 있도록 구성되어 있습니다.
이와 같이 단일 파일 내에서 고급 수준의 웹 디자인, 애니메이션, 인터랙션, 그리고 패럴랙스 효과 등을 구현한 포트폴리오 웹사이트를 구현할 수 있습니다. 여러분의 창의성과 필요에 따라 코드를 더욱 확장하여 발전시킬 수 있습니다.