Highly Styled Pagination - 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>Highly Styled Pagination</title> <style> body { font-family: Arial, sans-serif; background-color: #f3f4f6; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .pagination-container { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 10px; background-color: #fff; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); animation: fadeIn 1s ease-in-out; } .pagination-button { display: flex; justify-content: center; align-items: center; width: 40px; height: 40px; border-radius: 50%; background-color: #007bff; color: #fff; font-size: 18px; cursor: pointer; transition: transform 0.2s, background-color 0.2s; position: relative; } .pagination-button:hover { background-color: #0056b3; transform: scale(1.1); } .pagination-button:active { transform: scale(0.9); } .pagination-button.emoji { font-size: 24px; } .pagination-button .tooltip { display: none; position: absolute; bottom: 50px; left: 50%; transform: translateX(-50%); background-color: #333; color: #fff; padding: 5px; border-radius: 5px; white-space: nowrap; font-size: 12px; opacity: 0; transition: opacity 0.3s; } .pagination-button:hover .tooltip { display: block; opacity: 1; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } } .current-page { background-color: #28a745; } .current-page:hover { background-color: #218838; } .page-info { font-size: 16px; color: #555; } </style> </head> <body> <div class="pagination-container"> <div class="pagination-button emoji" id="first-page">📖<span class="tooltip">First Page</span></div> <div class="pagination-button emoji" id="prev-page">◀<span class="tooltip">Previous Page</span></div> <div class="pagination-button current-page" id="page-1">1</div> <div class="pagination-button" id="page-2">2</div> <div class="pagination-button" id="page-3">3</div> <div class="pagination-button emoji" id="next-page">▶<span class="tooltip">Next Page</span></div> <div class="pagination-button emoji" id="last-page">📗<span class="tooltip">Last Page</span></div> </div> <div class="page-info">Page <span id="current-page">1</span> of <span id="total-pages">3</span></div> <script> document.addEventListener('DOMContentLoaded', () => { const totalPages = 3; let currentPage = 1; const updatePageInfo = () => { document.getElementById('current-page').innerText = currentPage; Array.from(document.querySelectorAll('.pagination-button')).forEach(button => { button.classList.remove('current-page'); }); document.getElementById(`page-${currentPage}`).classList.add('current-page'); }; document.getElementById('first-page').addEventListener('click', () => { currentPage = 1; updatePageInfo(); }); document.getElementById('prev-page').addEventListener('click', () => { if (currentPage > 1) { currentPage -= 1; updatePageInfo(); } }); document.getElementById('next-page').addEventListener('click', () => { if (currentPage < totalPages) { currentPage += 1; updatePageInfo(); } }); document.getElementById('last-page').addEventListener('click', () => { currentPage = totalPages; updatePageInfo(); }); document.querySelectorAll('.pagination-button').forEach(button => { button.addEventListener('click', () => { if (button.id.startsWith('page-')) { currentPage = parseInt(button.id.split('-')[1]); updatePageInfo(); } }); }); updatePageInfo(); }); </script> </body> </html>