-
-
Save bryanrsebastian/0b46eb07fb09a7f5b688980238e6bb8f to your computer and use it in GitHub Desktop.
Simple Cookie Consent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.dp-cookie { | |
display: none; | |
position: fixed; | |
z-index: 11; | |
bottom: 18px; | |
left: 50%; | |
transform: translateX(-50%); | |
background-color: #2e2e2b; | |
width: calc(100% - 50px); | |
max-width: 1500px; | |
text-align: center; | |
padding: 10px 20px; | |
border-radius: 30px; | |
-webkit-box-shadow: 1px 1px 5px 0px rgb(0 0 0); | |
-moz-box-shadow: 1px 1px 5px 0px rgba(0, 0, 0, 0, 1); | |
box-shadow: 1px 1px 5px 0px rgb(0 0 0); | |
} | |
.dp-cookie p, | |
.dp-cookie button { | |
color: #ffffff; | |
font-size: 14px; | |
display: inline-block; | |
vertical-align: middle; | |
} | |
.dp-cookie p { | |
margin: 5px 0; | |
} | |
.dp-cookie button { | |
font-size: 14px; | |
background-color: #5e5e5e; | |
margin-left: 10px; | |
padding: 10px 20px; | |
border-radius: 20px; | |
cursor: pointer; | |
-webkit-transition: all 0.3s; | |
-moz-transition: all 0.3s; | |
-o-transition: all 0.3s; | |
-ms-transition: all 0.3s; | |
transition: all 0.3s; | |
} | |
.dp-cookie button:hover { | |
background-color: #1f1f1f; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- before </footer> --> | |
<div class="dp-cookie"> | |
<p>We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.</p> | |
<button>AGREE</button> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery( document ).ready( function( $ ) { | |
if ( document.cookie.indexOf( 'accepted_cookies=' ) < 0 ) | |
$( '.dp-cookie' ).fadeIn(); | |
$( '.dp-cookie button' ).on( 'click', function() { | |
document.cookie = 'accepted_cookies=yes;'; | |
$( '.dp-cookie' ).fadeOut(); | |
} ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment