Tell us what’s happening:
- Your portfolio should use at least one media query.
Failed:12. Your #navbar element should always be at the top of the viewport.
Where is me mistake?
Please give me correct code.
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Portfolio</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<nav id="navbar">
<ul>
<li><a href="#welcome-section">Welcome</a></li>
<li><a href="#project-section">Projects</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
<section id="welcome-section">
<h1>Welcome to My Portfolio</h1>
</section>
<section id="project-section">
<h2>My Projects</h2>
<div class="project-tile">
<h3>Project 1</h3>
<p>A brief description of the project.</p>
<a href="#">View Project</a>
</div>
<div class="project-tile">
<h3>Project 2</h3>
<p>Another awesome project.</p>
<a href="#">View Project</a>
</div>
</section>
<section id="contact">
<h2>Contact</h2>
<p>Email: example@example.com</p>
<a id="profile-link" href="https://github.com/yourusername" target="_blank">GitHub Profile</a>
</section>
</body>
</html>
/* file: styles.css */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
text-align: center;
}
#navbar {
position: fixed;
top: 0;
left: 0;
width: 100%;
background-color: #333;
padding: 10px 0;
text-align: center;
z-index: 1000;
}
#navbar ul {
list-style: none;
padding: 0;
margin: 0;
}
#navbar ul li {
display: inline-block;
margin: 0 15px;
}
#navbar ul li a {
color: white;
text-decoration: none;
font-size: 18px;
}
#welcome-section {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-color: #f4f4f4;
}
#project-section {
padding: 60px 20px;
margin-top:
}
.project-tile {
background-color: #e0e0e0;
padding: 20px;
margin: 10px auto;
width: 80%;
max-width: 400px;
border-radius: 8px;
}
.project-tile a {
display: inline-block;
margin-top: 10px;
color: blue;
text-decoration: none;
}
#contact {
padding: 20px;
}
@media screen and (max-width: 768px) {
#navbar {
display: flex;
flex-direction: column;
align-items: center;
}
#navbar ul {
display: flex;
flex-direction: column;
gap: 10px;
}
.project-tile {
width: 90%;
margin: 10px auto;
}
h1 {
font-size: 2rem;
}
.project-tile a {
font-size: 1.2rem;
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Challenge Information:
Build a Personal Portfolio - Build a Personal Portfolio