Webd File
Webd File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dynamic Web Page with JavaScript and CSS</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f4f8;
display: flex; flex-direction:
column; align-items: center;
margin: 0;
} h1 {
color: #333;
margin-top: 20px;
}
#dynamicBox { width:
200px; height: 200px;
background-color: #3498db;
display: flex;
align-items: center;
justify-content: center;
color: white; font-size:
20px; font-weight:
bold; margin-top:
20px;
transition: transform 0.3s, background-color 0.3s;
}
#changeColorButton, #toggleTextButton {
padding: 10px 20px; font-size: 16px;
margin: 10px; cursor: pointer;
border: none; border-radius: 5px;
background-color: #3498db; color:
white;
transition: background-color 0.3s;
}
#changeColorButton:hover, #toggleTextButton:hover {
background-color: #2980b9;
}
</style>
</head>
<body>
<h1>Interactive Box with JavaScript and CSS</h1>
<div id="dynamicBox">Hover Me!</div>
<button id="changeColorButton">Change Color</button>
<button id="toggleTextButton">Toggle Text</button>
<script>
const dynamicBox = document.getElementById('dynamicBox'); const
changeColorButton = document.getElementById('changeColorButton'); const
toggleTextButton = document.getElementById('toggleTextButton');
dynamicBox.addEventListener('mouseover', function() {
dynamicBox.style.transform = 'scale(1.1)';
});
dynamicBox.addEventListener('mouseout', function() {
dynamicBox.style.transform = 'scale(1)';
});
changeColorButton.addEventListener('click', function() {
const colors = ['#e74c3c', '#9b59b6', '#f1c40f', '#1abc9c'];
const randomColor = colors[Math.floor(Math.random() * colors.length)];
dynamicBox.style.backgroundColor = randomColor;
});
toggleTextButton.addEventListener('click', function() {
dynamicBox.textContent = dynamicBox.textContent === 'Hover Me!' ? 'Hello World!' : 'Hover Me!';
});
</script>
</body>
</html>
Output :
Practical 6
Utilize HTML/CSS and JavaScript frameworks (ReactJS, NextJS) to construct dynamic user interfaces.
Code : App.js
import React, { useState } from "react"; import
"./App.css";
function App() {
const [count, setCount] = useState(0); const [darkMode,
setDarkMode] = useState(false);
const incrementCount = () => setCount(count + 1); const
toggleTheme = () => setDarkMode(!darkMode);
return (
<div className={`App ${darkMode ? "dark" : "light"}`}>
<header className="App-header">
<h1>Dynamic User Interface</h1>
<p>Count: {count}</p>
<button onClick={incrementCount}>Increment Count</button>
<button onClick={toggleTheme}>
Switch to {darkMode ? "Light" : "Dark"} Mode
</button>
</header>
</div>
);
} export default App;
App.css
.App {
text-align: center; }
.App-logo { height:
40vmin; pointer-events:
none; }
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34; min-
height: 100vh; display: flex; flex-
direction: column; align-items:
center; justify-content: center; font-
size: calc(10px + 2vmin); color:
white;
}
.App-link { color:
#61dafb; }
@keyframes App-logo-spin { from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}}
Output :
Practical 7
Create various databases using SQL/MongoDB/or other to show interactivity.
CREATE DATABASE interactiveDB;
USE interactiveDB;
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL, email
VARCHAR(100) NOT NULL, password
VARCHAR(100) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
require("mongoose");
App;
require("mongoose");