<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700,800&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"/>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://www.cssscript.com/demo/scratch-ticket-javascript-canvas/ScratchIt.min.js"></script>
HTML
<div class="background">
<div class="forground">
<div class="crss"><i class="fa fa-times" aria-hidden="true"></i></div>
<div class="barcode_section">
<h2>Hi <br/>
<span>Deepak Verma </span></h2>
<p id="el_Text">You are eligible to win a Surprise Gift </p>
<h3>Scratch <span> & win </span></h3>
<div class="barcode">
<!--<img src="img/barcode.png" />-->
<div id="scratch"><img src="img/martuti-git-screch.png"></div>
<div class="click_to_cont">
<h2 id="showOnReveal">Click Here for continue</h2>
</div>
</div>
</div>
<div class="win_car_section">
<h3>Congratulations ! <span> Deepak Verma </span></h3>
<h5>You Won Maruti Suzuki ciaz </h5>
<div class="car-img"><img src="img/car.png"/></div>
<button class="btn winbtn">Continue </button>
<h6>Note: Model may vary subject to availability. Accessories shown may not be a part of standard equipment</h6>
</div>
</div>
</div>
css
/*popup start*/
.background{ width:100%; height:100%; position:fixed; left:0px; top:0px; display:block; z-index: 1;}
.background:before{width:100%; height:100%; background-color:rgba(0,0,0, 0.8); position:absolute; top:0px; left:0px; content:'';}
.forground {
background-color: #ffffff;
border-radius: 7px;
height: auto;
left: 50%;
padding: 55px 50px;
position: absolute;
top: 50%;
/* width: 750px; */
z-index: 100;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%,-50%);
width: 34%;
}
.forground img{ width:100%; height:100%; display:block;}
.crss{background-color: #3a3a3a; border-radius: 50%; color: #ffffff; font-size: 25px; height: 40px; padding-left: 10px; padding-top: 5px; position: absolute; right: -17px; top: -7px; width: 40px; cursor:pointer;}
.btttttn{ float:left; position:absolute; left:150px; top:100px; z-index:1;}
.forground h2 {
font-size: 35px;
font-weight: 400;
color: #333333;
text-transform: uppercase;
text-align: center; margin: 0px;}
.forground h2 span{ color: #5e0000; font-weight: bold;}
.forground p {
margin: 0px;
color: #666666;
text-align: center;
font-size: 16px;
margin-top: 20px;}
.forground h3{ text-align: center; font-size: 19px; margin-top: 15px;}
.forground h3 span{ font-weight: bold}
.forground h4 {
width: 80%;
margin: 0 auto;
text-align: center;
font-size: 14px;
font-weight: 400;
margin-top: 15px;}
.barcode {
width: 369px;
height: auto;
margin: 0 auto;
margin-top: 20px;}
.barcode img{ width:100%; display: block; height: auto;}
/*bar code screh code star*/
.barcode_section{ width: 100%; height: auto;}
#scratch {
position: relative;
display: inline-block;
font-size: 0;
margin-bottom: 20px;
width:100%; height:70px;
}
#scratch img {
width: 100%;
max-width: 916px;
height: auto;
}
#scratch.revealed canvas {
opacity: 0;
height: 0;
}
#scratch canvas {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
bottom: 0;
right: 0;
cursor: pointer;
will-change: transform;
transform: translate3d(0,0,0);
-ms-touch-action: none;
-webkit-touch-action: none;
-moz-touch-action: none;
touch-action: none;
transition: opacity 500ms ease-out 0ms,height 0ms linear 500ms;
}
#showOnReveal{
display: none;
}
.click_to_cont {
width: 100%;
/* display: flex; */
height: 20px;
text-align: center;}
.click_to_cont h2{ font-size: 15px; color: #000; cursor: pointer;}
/*bar code screh code end*/
/*win a car section start*/
.win_car_section {width: 100%; text-align: center; display: none;}
.win_car_section h3{ color: #333333; font-size: 30px; margin: 0px;}
.win_car_section h3 span{ color: #5e0000; font-weight: bold;}
.win_car_section h5 {
color: #333333;
font-size: 26px;
text-align: center;
width: 100%;
margin-top: 6px;}
.car-img {
width: 295px;
height: auto;
text-align: center;
margin: 0 auto;
margin-top: 25px;}
.car-img img{ width: 100%; height: auto; display: block;}
.win_car_section h6{color: #a78c3c; font-size: 10px; margin: 0px; margin-top: 20px;}
/*win a car section end*/
js
<script>
var containerEl = document.getElementById('scratch'),
showText = document.getElementById('showOnReveal')
elText = document.getElementById('el_Text')
overlayImgUrl = './img/barcode.png',
brushImgUrl = './img/brush.png',
revealPercent = 50;
// event handler that fades out the overlay once 50% of it has been removed
function onReveal(){
containerEl.className += ' revealed';
showText.style.display="block";
elText.textContent="You are eligible to win a luxury car Maruti Suzuki Ciaz";
// NOTE: really weird workaround to force Edge 16 to actually detect the css class name addition and render the fade out transition. getElementById doesn't work, it actually needs to be getElementsByTagName. Any style could be changed (like fontSize) to trigger the update
if(window.navigator.userAgent.indexOf("Edge") > -1){
document.getElementsByTagName('canvas')[0].style.width = '100%';
}
}
if(ScratchIt.isSupported()){
ScratchIt(containerEl, overlayImgUrl, brushImgUrl, onReveal, revealPercent);
}
</script>
<script type="text/javascript">
$(document).ready(function() {
$('.crss').click(function() {
$('.background').stop().fadeOut(1000)
});
$('#showOnReveal').click(function(){
$('.barcode_section').hide();
$(".win_car_section").show();
});
});
</script>
No comments:
Post a Comment