Coder Wrap provides free to use snippets Coder Wrap provides free to use snippets

Back to Others
Preview Source Code
Download
HTML
CSS
/**Accept Popup start**/
.accept-overlay {
  position: fixed;
  left: 0px;
  top: 0px;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0, 0.7);
  z-index: 99;
  pointer-events: none;
  transition: all .4s ease;
  opacity: 0;
}
.accept-popup {
  width: 400px;
  padding: 20px;
  border: 1px solid black;
  background: white;
  font-family: Arial;
  width: 100%;
  padding: 20px;
  border: 1px solid #000;
  background: #fff;
  max-width: 800px;
  margin: auto;
  position: fixed;
  left: 0px;
  right: 0px;
  transition: all .4s ease;
  top: 50%;
  transform: translateY(-50%);
  z-index: 99;
  pointer-events: none;
  opacity: 0;
}
.accept-policy .accept-overlay, .accept-policy .accept-popup {
  opacity: 1;
  pointer-events: auto;
}
.cmn-btn {
  background: #133C55;
  color: white;
  font-size: 1rem;
  padding: 12px 24px 12px 24px;
  font-size: 16px;
  transition: opacity 0.2s;
  margin-top:20px;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  cursor: pointer;
}
.accept.disabled-accept {
  pointer-events: none;
  opacity: 0.3;
}
.terms-and-conditions {
  overflow-y: auto;
  max-height:500px;
}
/**Accept Popup end**/
JS
// Wait for the DOM to be ready
document.addEventListener("DOMContentLoaded", function(event) {

// Add click event listener to accept policy button
document.querySelector('.accept-policy-btn').addEventListener('click', function() {
document.body.classList.add('accept-policy');
});

// Add click event listener to accept button
document.querySelector('.accept').addEventListener('click', function() {
document.body.classList.remove('accept-policy');
});

// Add scroll event listener to terms and conditions element
document.querySelector('.terms-and-conditions').addEventListener('scroll', function() {
if (this.scrollTop + this.clientHeight + 2 >= this.scrollHeight) {
document.querySelector('.accept').classList.remove('disabled-accept');
} else {
document.querySelector('.accept').classList.add('disabled-accept');
}
});
});

Related Snippets

Leave a comment

Your email address will not be published. Required fields are marked *