Professional Poll - MeggiTools
Run
Toggle Theme
Share Link
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Professional Poll</title> <style> body { font-family: 'Arial', sans-serif; background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .poll-container { background: #ffffff; border-radius: 15px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); padding: 30px; max-width: 500px; width: 100%; text-align: left; animation: fadeIn 1s ease-out; } @keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } .poll-header { font-size: 24px; margin-bottom: 20px; color: #333; } .poll-question { font-size: 20px; margin-bottom: 15px; } .poll-options { list-style: none; padding: 0; } .poll-options li { margin-bottom: 10px; } .poll-options input[type="radio"] { display: none; } .poll-options label { display: block; padding: 15px; border-radius: 8px; cursor: pointer; transition: background 0.3s, transform 0.3s; font-size: 18px; background: #f0f4f8; color: #555; } .poll-options input[type="radio"]:checked + label { background: #6a82fb; color: #fff; transform: scale(1.05); } .poll-options input[type="radio"] + label:hover { background: #e1e8ee; } .poll-buttons { margin-top: 20px; } .poll-buttons button { padding: 10px 20px; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; transition: background 0.3s; margin: 5px; } .poll-buttons .submit-btn { background: #28a745; color: #fff; } .poll-buttons .submit-btn:hover { background: #218838; } .poll-buttons .reset-btn { background: #dc3545; color: #fff; } .poll-buttons .reset-btn:hover { background: #c82333; } .result-container { display: none; text-align: center; margin-top: 20px; } .result-container h2 { margin-bottom: 15px; color: #333; } .result-bar { width: 100%; background: #e9ecef; border-radius: 8px; margin-bottom: 10px; position: relative; } .result-bar .bar { height: 30px; border-radius: 8px; background: #6a82fb; text-align: center; line-height: 30px; color: #fff; position: relative; z-index: 1; } .result-bar .bar::before { content: ""; position: absolute; left: 0; top: 0; height: 100%; border-radius: 8px; background: rgba(255, 255, 255, 0.2); animation: barAnim 2s infinite; } @keyframes barAnim { from { left: -100%; } to { left: 100%; } } </style> </head> <body> <div class="poll-container"> <div class="poll-header">🌟 Professional Poll 🌟</div> <div class="poll-question">What is your favorite programming language?</div> <ul class="poll-options"> <li> <input type="radio" id="option1" name="poll" value="JavaScript"> <label for="option1">JavaScript <span>⚡</span></label> </li> <li> <input type="radio" id="option2" name="poll" value="Python"> <label for="option2">Python <span>🐍</span></label> </li> <li> <input type="radio" id="option3" name="poll" value="Java"> <label for="option3">Java <span>☕</span></label> </li> <li> <input type="radio" id="option4" name="poll" value="C++"> <label for="option4">C++ <span>💻</span></label> </li> </ul> <div class="poll-buttons"> <button class="submit-btn" onclick="submitPoll()">Submit</button> <button class="reset-btn" onclick="resetPoll()">Reset</button> </div> <div class="result-container"> <h2>Results</h2> <div id="result1" class="result-bar"><div class="bar" style="width: 0%;">JavaScript</div></div> <div id="result2" class="result-bar"><div class="bar" style="width: 0%;">Python</div></div> <div id="result3" class="result-bar"><div class="bar" style="width: 0%;">Java</div></div> <div id="result4" class="result-bar"><div class="bar" style="width: 0%;">C++</div></div> </div> </div> <script> const results = { JavaScript: 0, Python: 0, Java: 0, 'C++': 0 }; let totalVotes = 0; function submitPoll() { const selectedOption = document.querySelector('input[name="poll"]:checked'); if (selectedOption) { const value = selectedOption.value; results[value]++; totalVotes++; displayResults(); } else { alert('Please select an option.'); } } function resetPoll() { document.querySelectorAll('input[name="poll"]').forEach(input => input.checked = false); document.querySelector('.result-container').style.display = 'none'; document.querySelector('.poll-options').style.display = 'block'; document.querySelector('.poll-buttons').style.display = 'block'; } function displayResults() { document.querySelector('.result-container').style.display = 'block'; document.querySelector('.poll-options').style.display = 'none'; document.querySelector('.poll-buttons').style.display = 'none'; Object.keys(results).forEach((key, index) => { const percentage = (results[key] / totalVotes) * 100; document.querySelector(`#result${index + 1} .bar`).style.width = `${percentage}%`; document.querySelector(`#result${index + 1} .bar`).innerText = `${key} (${Math.round(percentage)}%)`; }); } </script> </body> </html>