To move the name and title 20px up within the header, you can apply a negative top margin to the <h1> and <p> elements. Here's how you can modify the CSS to achieve that:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stylish Project Portfolio</title>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Montserrat', sans-serif;
margin: 0;
padding: 0;
color: #333;
background-color: #f3f2ef;
font-size: 0.8em;
display: flex;
}
header {
background: #283e4a;
color: white;
display: flex;
justify-content: flex-end;
align-items: center;
padding: 20px 48px;
width: 100%;
position: fixed;
top: 10px;
left: 0;
box-sizing: border-box;
box-shadow: 0 1.6px 4px rgba(0, 0, 0, 0.1);
}
header h1, header p {
margin-top: -20px; /* Move the name and title 20px up */
}
nav {
background: #fff;
width: 128px;
height: 100vh;
padding-top: 144px;
box-sizing: border-box;
position: fixed;
top: 0;
left: 0;
border-right: 0.8px solid #e0e0e0;
box-shadow: 1.6px 0 4px rgba(0, 0, 0, 0.1);
z-index: 2;
}
nav ul {
list-style: none;
padding: 0;
margin: 0;
}
nav ul li {
width: 100%;
}
nav ul li a {
display: block;
padding: 12px;
color: #333;
text-decoration: none;
text-align: center;
transition: background 0.3s, color 0.3s;
}
nav ul li a:hover, nav ul li a.active {
background: #e6f3ff;
color: #0073b1;
}
main {
margin-left: 152px;
padding: 110px 4px 4px;
width: calc(100% - 176px);
box-sizing: border-box;
}
section {
padding: 32px;
margin-bottom: 16px;
background: #fff;
border-radius: 6.4px;
box-shadow: 0 3.2px 6.4px rgba(0, 0, 0, 0.1);
display: none;
opacity: 0;
transform: translateY(16px);
transition: all 0.4s ease-in-out;
}
section.visible {
display: block;
opacity: 1;
transform: translateY(0);
}
section h2 {
color: #0073b1;
border-bottom: 1.6px solid #0073b1;
padding-bottom: 4px;
margin-bottom: 8px;
font-weight: 600;
font-size: 1.2em;
}
footer {
text-align: center;
padding: 8px 0;
background: #283e4a;
color: white;
position: fixed;
bottom: 10px;
width: 100%;
left: 0;
box-shadow: 0 -1.6px 4px rgba(0, 0, 0, 0.1);
font-size: 11.2px;
}
</style>
</head>
<body>
<header>
<div>
<h1>Darshan J Pardeshi</h1>
<p>Financial Business Process Analyst</p>
</div>
</header>
<nav>
<ul>
<li><a href="#about" onclick="showSection('about')">About Me</a></li>
<li><a href="#projects" onclick="showSection('projects')">Projects</a></li>
<li><a href="#services" onclick="showSection('services')">Services</a></li>
<li><a href="#contact" onclick="showSection('contact')">Contact</a></li>
</ul>
</nav>
<main>
<section id="projects">
<h2>My Projects</h2>
<div>
<h3>Project Title</h3>
<p>A brief description of the project showcasing its highlights and achievements.</p>
</div>
</section>
<section id="about">
<h2>About Me</h2>
<p>Here is an introduction about myself and my journey in the field of work.</p>
</section>
<section id="services">
<h2>Services</h2>
<ul>
<li>Service 1</li>
<li>Service 2</li>
<li>Service 3</li>
</ul>
</section>
<section id="contact">
<h2>Contact</h2>
<p>I am available for freelance work. Reach out to me at <a href="mailto:contact@example.com">contact@example.com</a> or call (123) 456-7890.</p>
</section>
</main>
<footer>
<p>© 2023 Stylish Project Portfolio</p>
</footer>
<script>
function showSection(sectionId) {
document.querySelectorAll('main section').forEach(section => {
section.classList.remove('visible');
});
document.querySelectorAll('nav ul li a').forEach(link => {
link.classList.remove('active');
});
document.getElementById(sectionId).classList.add('visible');
document.querySelector(`nav ul li a[href="#${sectionId}"]`).classList.add('active');
}
window.onload = function() {
showSection('about');
};
</script>
</body>
</html>
By setting margin-top: -20px; for the <h1> and <p> elements inside the header, they are moved 20 pixels up. Adjust the margin value if you need a different offset.