|
3 | 3 | <head> |
4 | 4 | <meta charset="UTF-8"> |
5 | 5 | <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> |
9 | 7 | <style> |
| 8 | + /* Reset */ |
| 9 | + * { margin: 0; padding: 0; box-sizing: border-box; } |
| 10 | + |
10 | 11 | body { |
11 | 12 | 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 { |
13 | 32 | text-align: center; |
14 | | - margin-top: 50px; |
| 33 | + max-width: 400px; |
| 34 | + width: 90%; |
15 | 35 | } |
| 36 | + |
| 37 | + h1, h2, p { |
| 38 | + margin-bottom: 20px; |
| 39 | + } |
| 40 | + |
16 | 41 | button { |
17 | 42 | padding: 10px 20px; |
18 | | - background: blue; |
19 | | - color: white; |
20 | 43 | border: none; |
21 | | - border-radius: 5px; |
| 44 | + border-radius: 25px; |
| 45 | + background: #fff; |
| 46 | + color: #2575fc; |
| 47 | + font-weight: bold; |
22 | 48 | 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; |
23 | 74 | } |
24 | 75 | </style> |
25 | 76 | </head> |
26 | 77 | <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> |
29 | 99 |
|
30 | | - <!-- JS yahi likh diya --> |
31 | 100 | <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); |
34 | 153 | } |
35 | 154 | </script> |
36 | 155 | </body> |
|
0 commit comments