1. Setting Up the Project
Start by creating your project folder with the following structure:
landing-page/
├── index.html
├── styles.css
├── script.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Landing Page</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header class="navbar">
<nav>
<h1 class="logo">MyBrand</h1>
<ul class="nav-links">
<li><a href="#features">Features</a></li>
<li><a href="#pricing">Pricing</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<section class="hero">
<div class="hero-content">
<h2>Build Modern Websites</h2>
<p>Responsive designs that captivate your audience.</p>
<button>Get Started</button>
</div>
<img src="hero-image.jpg" alt="Hero Image">
</section>
<section id="features">
<h2>Features</h2>
<p>Highlight your product's features here.</p>
</section>
<section id="pricing">
<h2>Pricing</h2>
<p>Affordable plans for everyone.</p>
</section>
<section id="contact">
<h2>Contact Us</h2>
<form>
<input type="email" placeholder="Your Email">
<button type="submit">Submit</button>
</form>
</section>
<footer>
<p>© 2024 MyB
rand. All Rights Reserved.</p>
</footer>
<script src="script.js"></script>
</body>
</html>
/* General Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
line-height: 1.6;
}
/* Navbar */
.navbar {
background: #4A00E0;
color: #fff;
padding: 10px 20px;
display: flex;
justify-content: space-between;
align-items: center;
}
.nav-links {
list-style: none;
display: flex;
}
.nav-links li {
margin-left: 20px;
}
.nav-links a {
color: #fff;
text-decoration: none;
}
/* Hero Section */
.hero {
display: flex;
justify-content: space-between;
align-items: center;
padding: 40px;
background: linear-gradient(135deg, #8E2DE2, #4A00E0);
color: #fff;
}
.hero-content h2 {
font-size: 2.5rem;
}
.hero img {
width: 40%;
}
/* Responsive Design */
@media (max-width: 768px) {
.hero {
flex-direction: column;
text-align: center;
}
.hero img {
width: 80%;
}
}
// script.js
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener("click", function(e) {
e.preventDefault();
document.querySelector(this.getAttribute("href")).scrollIntoView({
behavior: "smooth"
});
});
});
**4. Responsive and Engaging Design**
To make your landing page responsive:
Use flexbox and media queries for layouts.
Optimize images for different screen sizes.
Test responsiveness using browser developer tools.
5. Optional: Adding Animations
For modern aesthetics, use CSS animations.
Optional: Adding Animations
/* Button Hover */
button {
background: #fff;
color: #4A00E0;
border: none;
padding: 10px 20px;
cursor: pointer;
transition: all 0.3s ease-in-out;
}
button:hover {
background: #4A00E0;
color: #fff;
}
Final Thoughts
Building a responsive landing page requires balancing design, performance, and user experience. By using HTML, CSS, and JavaScript effectively, you can create a page that is visually appealing and functional.
What are your thoughts? Share your customizations and tips in the comments below! 😊
Top comments (0)