Elegant Table Press - 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>Elegant Table Press</title> <style> body { font-family: 'Helvetica Neue', sans-serif; background-color: #f8f9fa; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .table-container { width: 80%; margin: 20px auto; overflow: hidden; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.1); border-radius: 15px; animation: slideIn 1s ease-in-out; } table { width: 100%; border-collapse: collapse; } thead { background-color: #343a40; color: #fff; font-size: 1.2em; } th, td { padding: 15px; text-align: left; border-bottom: 1px solid #ddd; } tbody tr:nth-child(even) { background-color: #f2f2f2; } tbody tr:hover { background-color: #e9ecef; transition: background-color 0.3s ease; } th.sortable:hover { cursor: pointer; color: #ffc107; } .icon { margin-right: 8px; } @keyframes slideIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } } .tooltip { position: relative; display: inline-block; } .tooltip .tooltiptext { visibility: hidden; width: 140px; background-color: #555; color: #fff; text-align: center; border-radius: 6px; padding: 5px 0; position: absolute; z-index: 1; bottom: 125%; left: 50%; margin-left: -70px; opacity: 0; transition: opacity 0.3s; } .tooltip:hover .tooltiptext { visibility: visible; opacity: 1; } </style> </head> <body> <div class="table-container"> <table id="elegantTable"> <thead> <tr> <th class="sortable">Name <span class="icon">👤</span></th> <th class="sortable">Role <span class="icon">🎭</span></th> <th class="sortable">Team <span class="icon">👥</span></th> <th class="sortable">Country <span class="icon">🌍</span></th> </tr> </thead> <tbody> <tr> <td class="tooltip">Anna Bell<span class="tooltiptext">Team Leader</span></td> <td>Project Manager</td> <td>Development</td> <td>USA</td> </tr> <tr> <td class="tooltip">Mark Spencer<span class="tooltiptext">Senior Dev</span></td> <td>Developer</td> <td>Backend</td> <td>Canada</td> </tr> <tr> <td class="tooltip">Lisa Wong<span class="tooltiptext">UI/UX Specialist</span></td> <td>Designer</td> <td>Frontend</td> <td>UK</td> </tr> <tr> <td class="tooltip">John Doe<span class="tooltiptext">QA Expert</span></td> <td>Tester</td> <td>Quality Assurance</td> <td>Germany</td> </tr> </tbody> </table> </div> <script> document.querySelectorAll('th.sortable').forEach(header => { header.addEventListener('click', () => { const table = header.parentElement.parentElement.parentElement; const tbody = table.querySelector('tbody'); Array.from(tbody.querySelectorAll('tr')) .sort((a, b) => { const aText = a.querySelector(`td:nth-child(${header.cellIndex + 1})`).textContent.trim(); const bText = b.querySelector(`td:nth-child(${header.cellIndex + 1})`).textContent.trim(); return aText.localeCompare(bText); }) .forEach(tr => tbody.appendChild(tr)); }); }); </script> </body> </html>