Modern 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>Modern Table Press</title> <style> body { font-family: 'Arial', sans-serif; background-color: #eceff1; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .table-container { width: 90%; margin: 20px auto; overflow: hidden; background: #fff; box-shadow: 0 0 20px rgba(0,0,0,0.1); border-radius: 10px; animation: popIn 1s ease-in-out; } table { width: 100%; border-collapse: collapse; } thead { background-color: #00bfa5; color: #fff; font-size: 1.2em; text-align: center; } th, td { padding: 15px; border-bottom: 1px solid #ddd; text-align: center; } tbody tr:nth-child(even) { background-color: #f9f9f9; } tbody tr:hover { background-color: #f1f1f1; transition: background-color 0.3s ease; } th.sortable:hover { cursor: pointer; color: #ff5722; } .icon { margin-left: 5px; } @keyframes popIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } } .tooltip { position: relative; display: inline-block; } .tooltip .tooltiptext { visibility: hidden; width: 120px; background-color: #333; color: #fff; text-align: center; border-radius: 6px; padding: 5px 0; position: absolute; z-index: 1; bottom: 125%; left: 50%; margin-left: -60px; opacity: 0; transition: opacity 0.3s; } .tooltip:hover .tooltiptext { visibility: visible; opacity: 1; } </style> </head> <body> <div class="table-container"> <table id="modernTable"> <thead> <tr> <th class="sortable">Product <span class="icon">📦</span></th> <th class="sortable">Price <span class="icon">💲</span></th> <th class="sortable">Stock <span class="icon">📊</span></th> <th class="sortable">Category <span class="icon">🏷️</span></th> </tr> </thead> <tbody> <tr> <td class="tooltip">Laptop<span class="tooltiptext">Electronics</span></td> <td>$999</td> <td>20</td> <td>Gadgets</td> </tr> <tr> <td class="tooltip">Headphones<span class="tooltiptext">Accessories</span></td> <td>$199</td> <td>150</td> <td>Audio</td> </tr> <tr> <td class="tooltip">Chair<span class="tooltiptext">Furniture</span></td> <td>$150</td> <td>50</td> <td>Office</td> </tr> <tr> <td class="tooltip">Desk<span class="tooltiptext">Furniture</span></td> <td>$300</td> <td>30</td> <td>Office</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>