Cookie Consent Popup
Home
Snippets
Cookie Consent Popup
HTML
CSS
JS
<div class="cookie-banner" id="cookieBanner"> <p>We use cookies to improve your experience. Accept to continue.</p> <button id="acceptCookies">Accept</button> </div>
body { font-family: Arial, sans-serif; margin: 0; padding: 0; } .cookie-banner { position: fixed; bottom: 20px; left: 20px; right: 20px; background: #222; color: #fff; padding: 15px; border-radius: 10px; display: flex; justify-content: space-between; align-items: center; gap: 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); } .cookie-banner p { margin: 0; font-size: 14px; } .cookie-banner button { background: #27ae60; border: none; color: white; padding: 8px 14px; border-radius: 6px; cursor: pointer; }
const banner = document.getElementById("cookieBanner"); const button = document.getElementById("acceptCookies"); if (localStorage.getItem("cookiesAccepted")) { banner.style.display = "none"; } button.addEventListener("click", () => { localStorage.setItem("cookiesAccepted", true); banner.style.display = "none"; });
Ad #1
Ad #2
Scroll to Top