Build a HTML5 Birthday Greeting Card Generator Using Name & Photo Using Javascript Full Project For Beginners

 

 

 

index.html

 

 

<!DOCTYPE html>
<html>
  <head><title>Birthday wishes</title>
    <link rel="stylesheet" type="text/css" href="../assets/css/BirthdayGreeting.css">
  </head>
  <body style="margin-top: 300px; background-image: linear-gradient(to right, #333232 , black);">
    <div id="card">
    <div id="card-inside">
      <div class="wrap">
        <p>Hey Friend,</p>
        <!--Write a detailed message here-->
        <p>!!Write your message here!!</p>

        <!--Write a attractive phrase here-->
        <p>!Share your special phrase!
        </p>

        <p>Your Lovingly,</p>

        <!--Write your name here-->
        <p class="signed">Signature</p>
        
      </div>
    </div>

    <div id="card-front">
      <div class="wrap">
        <h1>Happy Birthday!</h1>
      </div>
      <button id="open">></button>
      <button id="close"><</button>
    </div>
  </div>

<div id="parent">
   <div class="message">Happy</div>
   <div class="message">Birthday</div>
   <div class="message">Friend</div>
</div>
 <script type="text/javascript" src="../assets/js/BirthdayGreeting.js"></script>
    
  </body>
  
</html>

 

 

birthdaygreeting.css

 

 

@import url(https://fonts.googleapis.com/css?family=Nobile:400italic,700italic);
@import url(https://fonts.googleapis.com/css?family=Dancing+Script);
* {
  box-sizing: border-box;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
}
body {
  background: #E5E5E5;
  background-image: url("/gray-floral.png");
  padding: 50px;
}

#card-front {
  color: #FFDFDF;
}

#card, #card-front, #card-inside {
  height: 680px;
}

.wrap {
    padding: 1.5em 2.5em;
    height: 100%;
}
#card-front, #card-inside {
  width: 50%;
  -webkit-box-shadow: 2px 2px 30px rgba(0, 0, 0, .25), 0 0 1px rgba(0, 0, 0, .5);
  -moz-box-shadow: 2px 2px 30px rgba(0, 0, 0, .25), 0 0 1px rgba(0, 0, 0, .5);
  box-shadow: 2px 2px 30px rgba(0, 0, 0, .25), 0 0 1px rgba(0, 0, 0, .5);
  position: absolute;
  left: 50%;
}


#card-inside .wrap {
    background: #FFEFEF;
    -webkit-box-shadow: inset 2px 0 1px rgba(0, 0, 0, .05);
    -moz-box-shadow: inset 2px 0 1px rgba(0, 0, 0, .05);
    box-shadow: inset 2px 0 1px rgba(0, 0, 0, .05);
}
#card {
    max-width: 960px;
    margin: 0 auto;
    transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    perspective: 5000px;
    -moz-perspective: 5000px;
    -webkit-perspective: 5000px;
    position: relative;
}

#card h1 {
    text-align: center;
    font-family: 'Nobile', sans-serif;
    font-style: italic;
    font-size: 70px;
    text-shadow: 
        4px 4px 0px rgba(0, 0, 0, .15),
        1px 1px 0 rgba(255, 200, 200, 255),
        2px 2px 0 rgba(255, 150, 150, 255),
        3px 3px 0 rgba(255, 125, 125, 255);
    color: #FFF;
}
#card-inside {
    font-size: 1.1em;
    line-height: 1.4;
    font-family: 'Nobile';
    color: f;
    font-style: italic;
}

p {
    margin-top: 1em;
}

p:first-child {
    margin-top: 0;
}

p.signed {
    margin-top: 1.5em;
    text-align: center;
    font-family: 'Dancing Script', sans-serif;
    font-size: 1.5em;
}

#card-front {
    background-color: #610abf;
    background-image: linear-gradient(top, #610abf 0%, #610abf 100%);
    background-image: -moz-linear-gradient(top, #610abf 0%, #610abf 100%);
    background-image: -webkit-linear-gradient(top, #610abf 0%, #610abf 100%);
            transform-origin: left;
       -moz-transform-origin: left;
    -webkit-transform-origin: left;
            transition:         transform 1s linear;
       -moz-transition:    -moz-transform 1s linear;
    -webkit-transition: -webkit-transform 1s linear;
    position: relative;
}

#card-front .wrap {
            transition: background 1s linear;
       -moz-transition: background 1s linear;
    -webkit-transition: background 1s linear;
}

#card-front button {
  position: absolute;
  bottom: 1em;
  right: -12px;
  background: #ffffff;
  color: #610abf;
  font-family: 'Nobile', sans-serif;
  font-style: italic;
  font-weight: bold;
  font-size: 1.5em;
  padding: .5em;
  border: none;
  cursor: pointer;
          box-shadow: 2px 2px 3px rgba(0, 0, 0, .25), 0 0 1px rgba(0, 0, 0, .4);
     -moz-box-shadow: 2px 2px 3px rgba(0, 0, 0, .25), 0 0 1px rgba(0, 0, 0, .4);
  -webkit-box-shadow: 2px 2px 3px rgba(0, 0, 0, .25), 0 0 1px rgba(0, 0, 0, .4);
}

#card-front button:hover,
#card-front button:focus {
  background: #F22;
}

#close {
  display: none;
}

#card.open-fully #close,
#card-open-half #close {
  display: inline;
}

#card.open-fully #open {
  display: none;
}


#card.open-half #card-front,
#card.close-half #card-front {
            transform: rotateY(-90deg);
       -moz-transform: rotateY(-90deg);
    -webkit-transform: rotateY(-90deg);
}
#card.open-half #card-front .wrap {
    background-color: rgba(0, 0, 0, .5);
}

#card.open-fully #card-front,
#card.close-half #card-front {
  background: #FFEFEF;
}

#card.open-fully #card-front {
    transform: rotateY(-180deg);
    -moz-transform: rotateY(-180deg);
    -webkit-transform: rotateY(-180deg);
}

#card.open-fully #card-front .wrap {
    background-color: rgba(0, 0, 0, 0);
}

#card.open-fully #card-front .wrap *,
#card.close-half #card-front .wrap * {
   display: none;
}

footer {
  max-width: 500px;
  margin: 40px auto;
  font-family: 'Nobile', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #888;
  text-align: center;
}

/*Balloon code*/
@media only screen and (min-width: 1490px) {
#parent {
  position: ;
  width: 400px;
  height: 100vh;
  overflow: hidden;
  visibility: hidden;

}
.message {
  position:absolute;
  left: 300px;
  bottom: -120px;
  height: 145px;
  width: 120px;
  background-color: rgba(182, 15, 97, 0.9);
  color: white;
  line-height: 115px;
  text-align: center;
  font-family: 'Nobile', sans-serif;
  font-weight: bold;
  border-radius: 80%;
  box-shadow:inset -10px -10px 0 rgba(0,0,0,0.07);
  animation: move 6s infinite linear;


}
.message::before {
  color: rgba(182, 15, 97, 0.9);
  position:absolute;
  bottom:-60px;
  left: 43px;  
  content:"^";
  font-size:2em;
}
.message:after {
  top:153px;
  left: 58px;
  position:absolute;
  height:250px;
  width:3px;
  margin:0 auto;
  content:"";
  background:rgba(0,0,0,0.2); 
}

.message:nth-child(2){
  left:700px;
  background-color:rgba(190, 61, 244, 0.9);
  animation-delay: 2s;
}
.message:nth-child(2)::before{
  color: rgba(190, 61, 244, 0.9);
}

.message:nth-child(3){
  left:1100px;
  background-color:rgba(45, 181, 167, 0.9);
  animation-delay: 4s;
}
.message:nth-child(3)::before{
  color: rgba(45, 181, 167, 0.9);;
}
@keyframes move {
  0% {
    bottom: -400px;
  }
  100% {
    bottom: 400px;
  }
}
}

 

See also  Build a PDF Document Generator in Javascript Using PDFMake & Mozilla PDF.js Library in Browser Full Tutorial For Beginners

 

birthdaygreeting.js

 

 

//Fetching audio
var sound = new Audio();
sound.src = "../assets/sounds/BirthdayGreeting.mp3";
var eff = document.getElementById('parent');


(function() {
  function $(id) {
    return document.getElementById(id);
  }

var card = $('card'),
openB = $('open'),
closeB = $('close'),
timer = null;

//Opening a wrap
console.log('wat', card);
openB.addEventListener('click', function () {
  sound.play();
  sound.loop = true;
  card.setAttribute('class', 'open-half');
  if (timer) clearTimeout(timer);
  timer = setTimeout(function () {
    card.setAttribute('class', 'open-fully');
    timer = null;

  }, 1000);
  timer = setTimeout(function () {
  eff.setAttribute("style","visibility: visible;");
  }, 2000);
  
});

//Closing a wrap
closeB.addEventListener('click', function () {
  eff.setAttribute("style","visibility: hidden;");
  card.setAttribute('class', 'close-half');
  if (timer) clearTimerout(timer);
  timer = setTimeout(function () {
    card.setAttribute('class', '');
    timer = null;
     
  }, 1000);
});
}());

Leave a Reply