Answers for "html cookies popup"

0

html cookies popup

<div class=’cookie-banner’ style=’display: none’>
<p>
    By using our website, you agree to our 
    <a href=’insert-link’>cookie policy</a>
  </p>
<button class=’close’>&times;</button>
</div>

<style>
	.cookie-banner {
  position: fixed;
  bottom: 40px;
  left: 10%;
  right: 10%;
  width: 80%;
  padding: 5px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #eee;
  border-radius: 5px;
  box-shadow: 0 0 2px 1px rgba(0, 0, 0, 0.2);
}
.close {
  height: 20px;
  background-color: #777;
  border: none;
  color: white;
  border-radius: 2px;
  cursor: pointer;
}
</style>

<script>
	if (localStorage.getItem(‘cookieSeen’) != ‘shown’) {
  $(‘.cookie-banner’).delay(2000).fadeIn();
  localStorage.setItem(‘cookieSeen’,’shown’)
};
$(‘.close’).click(function() {
  $(‘.cookie-banner’).fadeOut();
})
</script>
Posted by: Guest on August-05-2021

Browse Popular Code Answers by Language