Skip to content

Commit 20cfdd6

Browse files
authored
index.html
1 parent 62557ed commit 20cfdd6

1 file changed

Lines changed: 132 additions & 13 deletions

File tree

‎index.html‎

Lines changed: 132 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,153 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Mera Website</title>
7-
8-
<!-- CSS yahi likh diya -->
6+
<title>Rutu's Website</title>
97
<style>
8+
/* Reset */
9+
* { margin: 0; padding: 0; box-sizing: border-box; }
10+
1011
body {
1112
font-family: Arial, sans-serif;
12-
background: #f0f0f0;
13+
height: 100vh;
14+
background: linear-gradient(135deg, #6a11cb, #2575fc);
15+
color: white;
16+
display: flex;
17+
justify-content: center;
18+
align-items: center;
19+
overflow: hidden;
20+
}
21+
22+
.fade {
23+
opacity: 0;
24+
transition: opacity 1s ease-in-out;
25+
}
26+
27+
.fade.show {
28+
opacity: 1;
29+
}
30+
31+
.container {
1332
text-align: center;
14-
margin-top: 50px;
33+
max-width: 400px;
34+
width: 90%;
1535
}
36+
37+
h1, h2, p {
38+
margin-bottom: 20px;
39+
}
40+
1641
button {
1742
padding: 10px 20px;
18-
background: blue;
19-
color: white;
2043
border: none;
21-
border-radius: 5px;
44+
border-radius: 25px;
45+
background: #fff;
46+
color: #2575fc;
47+
font-weight: bold;
2248
cursor: pointer;
49+
transition: 0.3s;
50+
}
51+
52+
button:hover {
53+
background: #eee;
54+
}
55+
56+
.input-container {
57+
display: flex;
58+
align-items: center;
59+
justify-content: center;
60+
gap: 10px;
61+
}
62+
63+
input {
64+
padding: 10px;
65+
border-radius: 25px;
66+
border: none;
67+
outline: none;
68+
width: 60%;
69+
}
70+
71+
#dashboard h2 {
72+
font-size: 26px;
73+
margin-bottom: 10px;
2374
}
2475
</style>
2576
</head>
2677
<body>
27-
<h1>Welcome to My Website</h1>
28-
<button onclick="sayHello()">Click Me</button>
78+
<!-- Welcome Screen -->
79+
<div id="welcome" class="container fade show">
80+
<h1>Welcome 👋</h1>
81+
<button onclick="goToName()">Next</button>
82+
</div>
83+
84+
<!-- Name Input Screen -->
85+
<div id="nameScreen" class="container fade" style="display:none;">
86+
<h2>Provide us your name</h2>
87+
<p>For better conversation 😊</p>
88+
<div class="input-container">
89+
<input type="text" id="nameInput" placeholder="Enter your name">
90+
<button onclick="saveName()">Done</button>
91+
</div>
92+
</div>
93+
94+
<!-- Dashboard -->
95+
<div id="dashboard" class="container fade" style="display:none;">
96+
<h2 id="greeting"></h2>
97+
<p>Welcome to your dashboard 🚀</p>
98+
</div>
2999

30-
<!-- JS yahi likh diya -->
31100
<script>
32-
function sayHello() {
33-
alert("Hello Rutu! Website chal rha hai 😎");
101+
const welcome = document.getElementById("welcome");
102+
const nameScreen = document.getElementById("nameScreen");
103+
const dashboard = document.getElementById("dashboard");
104+
const greeting = document.getElementById("greeting");
105+
const nameInput = document.getElementById("nameInput");
106+
107+
// Agar user pehle se name save kar chuka hai
108+
window.onload = () => {
109+
const savedName = localStorage.getItem("username");
110+
if (savedName) {
111+
showDashboard(savedName);
112+
}
113+
};
114+
115+
function goToName() {
116+
fadeOut(welcome, () => {
117+
nameScreen.style.display = "block";
118+
fadeIn(nameScreen);
119+
});
120+
}
121+
122+
function saveName() {
123+
const name = nameInput.value.trim();
124+
if (name) {
125+
localStorage.setItem("username", name);
126+
fadeOut(nameScreen, () => {
127+
showDashboard(name);
128+
});
129+
} else {
130+
alert("Please enter your name 🙂");
131+
}
132+
}
133+
134+
function showDashboard(name) {
135+
greeting.textContent = `Hello, ${name}!`;
136+
dashboard.style.display = "block";
137+
fadeIn(dashboard);
138+
}
139+
140+
// Animation helpers
141+
function fadeOut(element, callback) {
142+
element.classList.remove("show");
143+
setTimeout(() => {
144+
element.style.display = "none";
145+
if (callback) callback();
146+
}, 1000); // 1s = same as CSS transition
147+
}
148+
149+
function fadeIn(element) {
150+
setTimeout(() => {
151+
element.classList.add("show");
152+
}, 50);
34153
}
35154
</script>
36155
</body>

0 commit comments

Comments
 (0)