Sure! Below is a complete HTML code with embedded CSS and JavaScript for a cool, modern, and interactive portfolio website. This code combines stylish design elements with interactive features to create an amazing user experience.
Simply copy the code into a file named index.html and open it in your web browser to see the result.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Awesome Portfolio</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
/* =================== Global Styles =================== */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
scroll-behavior: smooth;
}
body {
font-family: 'Arial', sans-serif;
color: #333;
background-color: #f5f5f5;
}
a {
text-decoration: none;
color: inherit;
}
/* =================== Navbar Styles =================== */
.navbar {
position: fixed;
width: 100%;
background-color: #333;
padding: 1em 2em;
display: flex;
align-items: center;
justify-content: space-between;
z-index: 1000;
}
.navbar .logo {
color: #fff;
font-size: 1.5em;
font-weight: bold;
}
.navbar ul {
display: flex;
list-style: none;
}
.navbar ul li {
margin-left: 1.5em;
}
.navbar ul li a {
color: #fff;
font-size: 1em;
transition: color 0.3s;
}
.navbar ul li a:hover {
color: #1abc9c;
}
/* Responsive Navbar */
.navbar .menu-icon {
display: none;
font-size: 1.5em;
color: #fff;
cursor: pointer;
}
@media (max-width: 768px) {
.navbar ul {
position: absolute;
top: 60px;
right: -100%;
flex-direction: column;
background-color: #333;
width: 200px;
transition: right 0.3s;
}
.navbar ul.active {
right: 0;
}
.navbar ul li {
margin: 1em 0;
text-align: center;
}
.navbar .menu-icon {
display: block;
}
}
/* =================== Hero Section Styles =================== */
.hero {
height: 100vh;
background-image: url('https://via.placeholder.com/1920x1080');
background-size: cover;
background-position: center;
position: relative;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
text-align: center;
}
.hero::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
.hero-content {
position: relative;
z-index: 1;
max-width: 800px;
}
.hero h1 {
font-size: 3em;
margin-bottom: 0.5em;
animation: slideInDown 1s ease-out;
}
.hero p {
font-size: 1.2em;
margin-bottom: 1em;
animation: fadeIn 2s ease-in-out;
}
.hero button {
padding: 0.75em 1.5em;
font-size: 1em;
border: none;
background-color: #1abc9c;
color: #fff;
cursor: pointer;
border-radius: 5px;
transition: background-color 0.3s;
}
.hero button:hover {
background-color: #16a085;
}
/* Animations */
@keyframes slideInDown {
from {
opacity: 0;
transform: translateY(-100px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* =================== Sections Styles =================== */
section {
padding: 4em 2em;
}
section h2 {
text-align: center;
margin-bottom: 1em;
font-size: 2.5em;
color: #333;
position: relative;
}
section h2::after {
content: '';
width: 50px;
height: 4px;
background-color: #1abc9c;
position: absolute;
left: 50%;
bottom: -10px;
transform: translateX(-50%);
}
/* =================== About Section =================== */
.about {
background-color: #fff;
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: center;
}
.about .about-image, .about .about-text {
flex: 1 1 300px;
margin: 1em;
}
.about .about-image img {
width: 100%;
border-radius: 10px;
}
.about .about-text p {
font-size: 1.1em;
line-height: 1.6;
}
/* =================== Portfolio Section =================== */
.portfolio {
background-color: #f5f5f5;
}
.portfolio .projects {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.portfolio .project {
width: 300px;
margin: 1em;
background-color: #fff;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
transition: transform 0.3s;
cursor: pointer;
}
.portfolio .project:hover {
transform: translateY(-10px);
}
.portfolio .project img {
width: 100%;
height: auto;
}
.portfolio .project-info {
padding: 1em;
}
.portfolio .project-info h3 {
margin-bottom: 0.5em;
}
.portfolio .project-info p {
font-size: 0.9em;
color: #666;
}
/* =================== Contact Section =================== */
.contact {
background-color: #fff;
}
.contact form {
max-width: 600px;
margin: 0 auto;
display: flex;
flex-direction: column;
}
.contact form input, .contact form textarea {
padding: 1em;
margin-bottom: 1em;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 1em;
}
.contact form button {
padding: 1em;
font-size: 1em;
border: none;
background-color: #1abc9c;
color: #fff;
cursor: pointer;
border-radius: 5px;
transition: background-color 0.3s;
}
.contact form button:hover {
background-color: #16a085;
}
/* =================== Footer Styles =================== */
footer {
background-color: #333;
color: #fff;
padding: 2em;
text-align: center;
}
footer p {
margin-bottom: 1em;
}
footer .socials {
display: flex;
justify-content: center;
}
footer .socials a {
color: #fff;
margin: 0 0.5em;
font-size: 1.5em;
transition: color 0.3s;
}
footer .socials a:hover {
color: #1abc9c;
}
/* =================== Scroll To Top Button =================== */
#scrollTopBtn {
position: fixed;
bottom: 40px;
right: 40px;
padding: 0.75em 1em;
background-color: #1abc9c;
color: #fff;
border: none;
border-radius: 50%;
font-size: 1.5em;
cursor: pointer;
display: none;
z-index: 100;
transition: background-color 0.3s;
}
#scrollTopBtn:hover {
background-color: #16a085;
}
</style>
</head>
<body>
<!-- =================== Navbar =================== -->
<nav class="navbar">
<div class="logo">MyPortfolio</div>
<div class="menu-icon" onclick="toggleMenu()">☰</div>
<ul>
<li><a href="#hero">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#portfolio">Projects</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
<!-- =================== Hero Section =================== -->
<section class="hero" id="hero">
<div class="hero-content">
<h1>Hi, I'm Your Name</h1>
<p>I'm a Web Developer who creates amazing websites.</p>
<button onclick="scrollToSection('portfolio')">View My Work</button>
</div>
</section>
<!-- =================== About Section =================== -->
<section class="about" id="about">
<h2>About Me</h2>
<div class="about-content">
<div class="about-image">
<img src="https://via.placeholder.com/500" alt="About Me">
</div>
<div class="about-text">
<p>
I'm a passionate web developer with experience in creating dynamic and responsive websites using modern web technologies. I love turning ideas into reality and am always excited to take on new challenges.
</p>
</div>
</div>
</section>
<!-- =================== Portfolio Section =================== -->
<section class="portfolio" id="portfolio">
<h2>My Projects</h2>
<div class="projects">
<!-- Project 1 -->
<div class="project" onclick="openModal(1)">
<img src="https://via.placeholder.com/300x200" alt="Project 1">
<div class="project-info">
<h3>Project One</h3>
<p>Brief description of the project.</p>
</div>
</div>
<!-- Project 2 -->
<div class="project" onclick="openModal(2)">
<img src="https://via.placeholder.com/300x200" alt="Project 2">
<div class="project-info">
<h3>Project Two</h3>
<p>Brief description of the project.</p>
</div>
</div>
<!-- Project 3 -->
<div class="project" onclick="openModal(3)">
<img src="https://via.placeholder.com/300x200" alt="Project 3">
<div class="project-info">
<h3>Project Three</h3>
<p>Brief description of the project.</p>
</div>
</div>
<!-- Add more projects as needed -->
</div>
</section>
<!-- =================== Contact Section =================== -->
<section class="contact" id="contact">
<h2>Contact Me</h2>
<form onsubmit="submitForm(event)">
<input type="text" name="name" placeholder="Your Name" required>
<input type="email" name="email" placeholder="Your Email" required>
<textarea name="message" rows="6" placeholder="Your Message" required></textarea>
<button type="submit">Send Message</button>
</form>
</section>
<!-- =================== Footer =================== -->
<footer>
<p>© 2023 Your Name. All Rights Reserved.</p>
<div class="socials">
<a href="#" target="_blank">🌐</a>
<a href="#" target="_blank">🐦</a>
<a href="#" target="_blank">💼</a>
<!-- Add your social media links -->
</div>
</footer>
<!-- =================== Scroll To Top Button =================== -->
<button id="scrollTopBtn" onclick="scrollToTop()">▲</button>
<!-- =================== Modal (Hidden by Default) =================== -->
<div id="projectModal" style="display:none;">
<!-- Modal content will be injected by JavaScript -->
</div>
<!-- =================== JavaScript =================== -->
<script>
// Toggle Mobile Menu
function toggleMenu() {
const menu = document.querySelector('.navbar ul');
menu.classList.toggle('active');
}
// Smooth Scroll to Section
function scrollToSection(sectionId) {
document.getElementById(sectionId).scrollIntoView({ behavior: 'smooth' });
}
// Scroll to Top
function scrollToTop() {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
// Show Scroll To Top Button
window.onscroll = function() {
const scrollBtn = document.getElementById('scrollTopBtn');
if (document.body.scrollTop > 500 || document.documentElement.scrollTop > 500) {
scrollBtn.style.display = "block";
} else {
scrollBtn.style.display = "none";
}
};
// Submit Contact Form
function submitForm(event) {
event.preventDefault();
alert('Thank you for your message!');
event.target.reset();
}
// Open Project Modal
function openModal(projectNumber) {
alert('Project ' + projectNumber + ' clicked!');
// Implement modal functionality as needed
}
// Close Mobile Menu on Link Click
document.querySelectorAll('.navbar ul li a').forEach(link => {
link.addEventListener('click', () => {
const menu = document.querySelector('.navbar ul');
if (menu.classList.contains('active')) {
menu.classList.remove('active');
}
});
});
</script>
</body>
</html>
Instructions to Customize Your Portfolio:
-
Save the File: Copy the code and paste it into a file named index.html.
-
Update Personal Information:
- Replace
"Your Name" with your actual name.
- Update the hero section with a personal introduction.
- Edit the about section with your own bio.
-
Add Your Projects:
- Replace the placeholder images with images of your projects.
- Update project titles and descriptions.
- Implement the
openModal function to display more details about each project, if desired.
-
Customize Social Media Links:
- In the footer, update the
href attributes with your social media profile links.
- Replace the placeholders with appropriate icons or text.
-
Images:
- Replace image URLs (
https://via.placeholder.com/...) with the paths to your own images.
-
Enhance Styles:
- Adjust colors, fonts, and other styles in the
<style> section to match your personal branding.
-
Test Your Website:
- Open
index.html in a web browser to see your portfolio in action.
- Test all links, buttons, and interactive elements to ensure they work correctly.
-
Publish Your Portfolio (Optional):
- You can host your website using platforms like GitHub Pages, Netlify, or any web hosting service.
Features of This Portfolio Website:
- Responsive Design: The layout adapts to different screen sizes, including mobile devices.
- Interactive Navbar: Smooth scrolling to sections and a mobile-friendly menu.
- Hero Section: Captivating introduction with an engaging call-to-action button.
- About Section: Space to showcase your biography and skills.
- Portfolio Section: Display your projects with hover effects and clickable items.
- Contact Form: Users can send you messages directly from the website.
- Scroll-To-Top Button: Easy navigation back to the top of the page.
- Footer with Social Links: Direct visitors to your social media profiles.
Tips to Make It Even More Awesome:
- Animations: Incorporate CSS animations or libraries like AOS (Animate On Scroll) for more dynamic effects.
- Modal Windows: Enhance the project section by displaying project details in modal windows.
- Custom Fonts: Use Google Fonts to include custom typography that matches your style.
- Optimizations: Compress images for faster loading times and consider adding meta tags for SEO.
Enjoy building your amazing and interactive portfolio website!