Display a cookie consent message with accept and reject buttons.

by davidxmartins

HTML

<!-- COOKIES CONSENT -->
  <div id="cookie-card">
    <div class="cookie-card-content">
      <p>Usamos cookies do <strong>Google Analytics</strong> para melhorar o site.<br>
Nenhum dado pessoal Ă© recolhido.</p>
      <div class="cookie-card-buttons">
        <button data-action="reject" class="btn-secondary">Recusar</button>
        <button data-action="accept" class="btn-primary">Aceitar</button>
      </div>
    </div>
  </div>

CSS

/*
===========================
COOKIES CONSENT
===========================
*/

#cookie-card {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  /*display: none;*/  /* restore after editing */
  display: flex !important; /* remove after editing */
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-family: "Inter Tight", sans-serif;
  font-weight: 400;
  color: #333;
}

#cookie-card.show {
  display: flex;
}

#cookie-card .cookie-card-content {
  background: #e9d7bd;
  max-width: 420px;
  width: 90%;
  padding: 1.8rem;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  text-align: center;
}

#cookie-card .cookie-card-content p {
  margin-bottom: 1.2rem;
  font-size: 1rem;
  color: #22140b;
  line-height: 1.5;
}

#cookie-card .cookie-card-buttons {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
}

#cookie-card .btn-primary {
  background: #617c47;
  color: #fff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}

#cookie-card .btn-primary:hover { background: #40572a; }

#cookie-card .btn-secondary {
  background: #c75b3a;
  color: #ffffff;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  cursor: pointer;
  border: none;
}

#cookie-card .btn-secondary:hover { background: #a13021; }