Home Works
Home Works
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Advanced Responsive Web Page</title>
</head>
<body>
<!-- Header Section with Navigation -->
<header class="sticky-header">
<nav class="navbar">
<div class="brand-logo">MyWebsite</div>
<div class="hamburger" onclick="toggleMenu()">☰</div>
<ul id="navMenu" class="nav-links">
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<script src="script.js"></script>
</body>
</html>
Homework css
/* Basic Reset */
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, sans-serif;
}
/* Header Section */
.sticky-header {
position: sticky;
top: 0;
background-color: #333;
color: white;
z-index: 1000;
}
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 20px;
}
.brand-logo {
font-size: 1.5em;
font-weight: bold;
}
.nav-links {
list-style-type: none;
display: flex;
}
.nav-links li {
margin: 0 15px;
}
.nav-links a {
color: white;
text-decoration: none;
transition: color 0.3s ease;
}
.nav-links a:hover {
color: #f00;
}
.hamburger {
font-size: 2em;
display: none;
cursor: pointer;
}
/* Hero Section */
.hero {
background: url('https://via.placeholder.com/1200x500') no-repeat center
center/cover;
height: 500px;
position: relative;
display: flex;
justify-content: center;
align-items: center;
color: white;
}
.hero-overlay {
background-color: rgba(0, 0, 0, 0.6);
padding: 20px;
text-align: center;
}
.cta-button {
padding: 10px 20px;
margin-top: 20px;
border: none;
background-color: #ff6347;
color: white;
cursor: pointer;
transition: background-color 0.3s ease;
}
.cta-button:hover {
background-color: #f00;
}
.card {
background: white;
padding: 20px;
border: 1px solid #ddd;
text-align: center;
transition: transform 0.3s ease;
}
.card:hover {
transform: scale(1.05);
}
.card img {
width: 100%;
height: auto;
}
.read-more {
display: block;
margin-top: 10px;
color: #007bff;
text-decoration: none;
transition: color 0.3s ease;
}
.read-more:hover {
color: #f00;
}
/* Testimonial Section */
.testimonials {
padding: 40px;
background-color: #f5f5f5;
text-align: center;
}
.testimonial-slider {
display: flex;
gap: 20px;
overflow-x: auto;
}
.testimonial {
background: #fff;
padding: 20px;
border: 1px solid #ddd;
min-width: 300px;
}
/* Footer Section */
footer {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
}
.social-media {
margin-bottom: 10px;
}
.social-media a {
margin: 0 10px;
color: white;
text-decoration: none;
transition: color 0.3s ease;
}
.social-media a:hover {
color: #f00;
}
/* Responsive Styles */
@media (max-width: 768px) {
.nav-links {
display: none;
flex-direction: column;
background: #333;
position: absolute;
top: 50px;
right: 20px;
width: 150px;
padding: 20px;
}
.nav-links.nav-expanded {
display: flex;
}
.hamburger {
display: block;
}
}
JavaScript
function toggleMenu() {
const nav = document.getElementById("navMenu");
nav.classList.toggle("nav-expanded");
}
Question 2
HTML ( registration form)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Enhanced Registration Form</title>
</head>
<body>
<!-- Registration Form -->
<form id="registrationForm">
<h2>User Registration</h2>
<label for="password">Password:</label>
<input type="password" id="password" name="password" placeholder="Enter your
password" required>
<label>Gender:</label>
<input type="radio" name="gender" value="Male" required> Male
<input type="radio" name="gender" value="Female"> Female
<input type="radio" name="gender" value="Other"> Other
<label>Interests:</label>
<input type="checkbox" name="interest" value="Coding"> Coding
<input type="checkbox" name="interest" value="Music"> Music
<input type="checkbox" name="interest" value="Sports"> Sports
<input type="checkbox" name="interest" value="Reading"> Reading
<input type="checkbox" name="interest" value="Traveling"> Traveling
<label for="country">Country:</label>
<select id="country" name="country" required>
<option value="">Select your country</option>
<option value="USA">USA</option>
<option value="UK">UK</option>
<option value="Canada">Canada</option>
<option value="Australia">Australia</option>
<option value="India">India</option>
</select>
<button type="submit">Submit</button>
</form>
<script src="script.js"></script>
</body>
</html>
/* Form Styling */
form {
width: 50%;
margin: 20px auto;
padding: 20px;
border: 1px solid #ddd;
background: #f9f9f9;
border-radius: 10px;
}
label {
display: block;
margin-top: 10px;
font-weight: bold;
}
button {
margin-top: 20px;
background: #007bff;
color: white;
cursor: pointer;
transition: background 0.3s ease;
}
button:hover {
background: #0056b3;
}
/* Modal Styling */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
justify-content: center;
align-items: center;
}
.modal-content {
background: white;
padding: 20px;
border-radius: 10px;
width: 80%;
max-width: 500px;
text-align: center;
}
.close-button {
float: right;
cursor: pointer;
font-size: 1.5em;
}
JavaScript
document.addEventListener("DOMContentLoaded", () => {
// Load data from local storage
const fields = ["fullName", "email", "country", "comments"];
fields.forEach(field => {
if (localStorage.getItem(field)) {
document.getElementById(field).value = localStorage.getItem(field);
}
});
document.getElementById("registrationForm").addEventListener("submit", function
(event) {
event.preventDefault();
function showModal() {
const userDetails = `
Full Name: ${document.getElementById("fullName").value}<br>
Email: ${document.getElementById("email").value}<br>
Gender: ${document.querySelector('input[name="gender"]:checked').value}<br>
Country: ${document.getElementById("country").value}<br>
Comments: ${document.getElementById("comments").value}
`;
document.getElementById("userDetails").innerHTML = userDetails;
document.getElementById("modal").style.display = "flex";
}
function closeModal() {
document.getElementById("modal").style.display = "none";
}
HTML grid layout
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="grid-styles.css">
<title>CSS Grid Layout</title>
</head>
<body>
<div class="container">
<!-- Header Section -->
<header class="header">
<div class="logo">Logo</div>
<nav class="nav">
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
.header {
grid-area: header;
background: #333;
color: white;
padding: 10px;
display: flex;
justify-content: space-between;
align-items: center;
}
.nav ul {
list-style-type: none;
display: flex;
}
.nav li {
margin-left: 20px;
}
.nav a {
color: white;
text-decoration: none;
}
.sidebar {
grid-area: sidebar;
background: #f4f4f4;
padding: 20px;
}
.content {
grid-area: content;
display: grid;
grid-template-columns: 1fr;
gap: 20px;
}
.article {
background: #fff;
padding: