Assignment 04
Question 01
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create a styled navigation bar using CSS</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
nav {
background-color: #875de2;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.navbar {
display: flex;
justify-content: center;
align-items: center;
padding: 14px 0;
}
.navbar a {
color: white;
text-decoration: none;
margin: 0 15px;
padding: 8px 16px;
border-radius: 4px;
transition: background-color 0.3s ease;
}
.navbar a:hover {
background-color: #ec16f4;
}
.navbar a.active {
background-color: white;
color: #333;
font-weight: bold;
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
@media (max-width: 600px) {
.navbar {
flex-direction: column;
}
.navbar a {
margin: 10px 0;
width: 80%;
text-align: center;
}
}
p{
text-align: center;
font-size: 18px;
color: #333;
}
</style>
</head>
<body>
<nav>
<div class="navbar">
<a href="#" class="active">Home</a>
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Contact</a>
</div>
</nav>
<p>Name: Ranveer Kumar Gond</p>
<p>Roll No: 2404850100134</p>
</body>
</html>
Preview
Question 02
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create a student marks table with CSS styling</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #f4f4f4;
}
table {
width: 100%;
border-collapse: collapse;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
th, td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #875de2;
color: white;
}
tr:nth-child(even) {
background-color: #f9f9f9;
}
tr:hover {
background-color: #ec16f4;
color: white;
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>Name</th>
<th>Roll No</th>
<th>Subject</th>
<th>Marks</th>
</tr>
</thead>
<tbody>
<tr>
<td>Ranveer Kumar Gond</td>
<td>2404850100134</td>
<td>Physics</td>
<td>90</td>
</tr>
<tr>
<td>Mukteshwar Vishwakarma</td>
<td>2404850100110</td>
<td>Mathematics</td>
<td>75</td>
</tr>
<tr>
<td>Ranveer Kapoor</td>
<td>2404850100133</td>
<td>Physics</td>
<td>80</td>
</tr>
<tr>
<td>Ranveer Kumar Gond</td>
<td>2404850100134</td>
<td>Physics</td>
<td>90</td>
</tr>
<tr>
<td>Mukteshwar Vishwakarma</td>
<td>2404850100110</td>
<td>Mathematics</td>
<td>75</td>
</tr>
<tr>
<td>Ranveer Kapoor</td>
<td>2404850100133</td>
<td>Physics</td>
<td>80</td>
</tr>
<tr>
<td>Ranveer Kumar Gond</td>
<td>2404850100134</td>
<td>Physics</td>
<td>90</td>
</tr>
</tbody>
</table>
</body>
</html>
Preview
Question 03
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create a simple webpage with a fixed background image</title>
<style>
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background: url('https://images.unsplash.com/photo-1506744038136-46273834b3fb?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8Zm9yZXN0JTIwYmFja2dyb3VuZHxlbnwwfHwwfHx8MA%3D%3D&w=1000&q=80') no-repeat center center fixed;
background-size: cover;
color: white;
text-align: center;
height: 100vh;
justify-content: center;
align-items: center;
}
h1 {
background-color: rgba(0, 0, 0, 0.5);
padding: 20px;
border-radius: 10px;
}
section {
background-color: rgba(0, 0, 0, 0.5);
margin: 20px;
padding: 20px;
border-radius: 10px;
}
section:hover {
border: rgb(241, 79, 10) 5px solid;
}
</style>
</head>
<body>
<h1>Welcome to My Webpage</h1>
<section>
<p style="text-align: left;">Name: Ranveer Kumar Gond <br> Roll No: 2404850100134 <br> Branch: CSE</p>
</section>
<section>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ea, deleniti hic tempore unde quod voluptatem qui ducimus odit quisquam excepturi culpa perspiciatis corrupti nam dicta eos inventore expedita ut id!</p>
</section>
<section>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Saepe dolores architecto numquam corrupti totam molestiae quae alias, perspiciatis voluptatibus, quod maiores cumque porro velit impedit mollitia accusamus. Quo, vero maiores.</p>
</section>
</body>
</html>
Preview
Question 04
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Show Date & Time</title>
<style>
body {
background-image: url('https://images.unsplash.com/photo-1506744038136-46273834b3fb?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8Zm9yZXN0JTIwYmFja2dyb3VuZHxlbnwwfHwwfHx8MA%3D%3D&w=1000&q=80');
color: white;
background-size: cover;
text-align: center;
padding-top: 100px;
height: 100vh;
}
button {
background-color: #ffffff;
color: #2575fc;
border: none;
padding: 10px 20px;
font-size: 18px;
cursor: pointer;
border-radius: 8px;
transition: 0.3s;
}
button:hover {
background-color: #2575fc;
color: white;
}
p {
font-size: 20px;
margin-top: 20px;
background-color: orange;
padding: 10px;
display: inline-block;
}
</style>
</head>
<body>
<h1>JavaScript Button Click Event</h1>
<button onclick="showDateTime()">Show Date & Time</button><br>
<p id="datetime"></p>
<script>
function showDateTime() {
const now = new Date();
document.getElementById("datetime").innerText = now.toString();
setInterval(showDateTime,1000)
}
</script>
</body>
</html>
Preview
Question 05
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Change Text Color</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f0f0f0;
text-align: center;
margin-top: 100px;
}
p {
font-size: 24px;
color: black;
transition: color 0.4s ease;
}
button {
padding: 10px 20px;
font-size: 18px;
background-color: #007bff;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
transition: 0.3s;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<h1>JavaScript Text Color Changer</h1>
<p id="text">This text will change its color when you click the button!</p>
<button onclick="changeColor()">Change Color</button>
<script>
function changeColor() {
const colors = ["red", "blue", "green"];
const randomColor = colors[Math.floor(Math.random() * colors.length)];
document.getElementById("text").style.color = randomColor;
}
</script>
</body>
</html>
Preview