TutorialsX-mas

how to create a Christmas Card using HTML CSS JS

how to create a Christmas Card using HTML CSS JS

how to create a Christmas Card using HTML CSS JS

Before We Start

Every developers need, clean and modern elements to develop their websites, It contain pictures and a user interface element within a website. The most important one and the first section that the user sees when he/she enters a website. how to create a Christmas Card using HTML CSS JS

So if you are a person who wishes to develop a website, you have to know how to create that properly.

how to create a Christmas Card using HTML CSS JS

We are here to solve your problem. In this article we discuss how to create this elements. Before we start please read the below articles which easier you to understand the process, if you are new to development.

Step 1 – Add HTML

It’s too easy and simple. Just copy and paste below code in your HTML editor between <body> </body> tag.

<html>
  <div class="card">
    <div class="card-page cart-page-front">
      <div class="card-page cart-page-outside"></div>
      <div class="card-page cart-page-inside">
        <span class="merry-christmas">
          <img src="https://i.imgur.com/fQCCtFI.png" alt="pling_logo" />
        </span>
      </div>
    </div>
    <div class="Lorem Ipsum is simply dummy text of the printing and typesetting industry.
        <br><br> Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
        <br><br><i>Pling</i></p>
    </div>
  </div>
  <span class="click-icon">
    <svg viewBox="0 0 40 45" xmlns="http://www.w3.org/2000/svg">
      <path fill="#1165ae" d="M31.6 17.7V26c0 1.9-.7 3.7-2 5.1v.9c0 1.6-1.3 3-3 3h-8.4c-1.6 0-3-1.3-3-3 0-.6.5-1 1-1s1 .4 1 1c0 .5.4 1 1 1h8.4c.5 0 1-.4 1-1v-1.2-.3-.1c0-.1.1-.2.2-.3 1.1-1.1 1.7-2.5 1.7-4v-8.3c0-.3-.1-.5-.3-.7-.1-.1-.5-.4-1-.3-.4.1-.8.6-.8 1.1v2.4c0 .6-.5 1-1 1s-1-.4-1-1v-5.5c0-.3-.1-.5-.3-.7s-.4-.3-.7-.3c-.5 0-1 .5-1 1v5.5c0 .6-.5 1-1 1s-1-.4-1-1v-8.5c0-.3-.1-.5-.3-.7s-.4-.3-.7-.3c-.5 0-1 .5-1 1v8.5c0 .6-.5 1-1 1s-1-.4-1-1V7.7c0-.3-.1-.5-.3-.7-.1-.1-.5-.4-1-.3-.4.1-.8.6-.8 1.1V20c0 .4-.2.8-.6.9-.4.2-.8.1-1.1-.2L11 18.1c-.6-.6-1.6-.6-2.2.1-.5.6-.4 1.5.2 2.1l7 7c.4.4.4 1 0 1.4-.2.2-.5.3-.7.3-.3 0-.5-.1-.7-.3l-7-7.1c-1.3-1.3-1.5-3.5-.3-4.8C8 16 9 15.5 10 15.5c.9 0 1.8.4 2.5 1l.9.9V7.9c0-1.4.9-2.7 2.3-3 1-.3 2.1 0 2.8.8.6.6.9 1.3.9 2.1V9c.3-.1.7-.2 1-.2.8 0 1.5.3 2.1.9s.9 1.3.9 2.1v.2c.3-.1.7-.2 1-.2.8 0 1.5.3 2.1.9s.9 1.3.9 2.1v.2c.1 0 .2-.1.3-.1 1-.3 2.1 0 2.8.8.8.5 1.1 1.3 1.1 2z" />
      <text x="20" y="43" class="click-text" fill="#1165ae" text-anchor="middle">
        clique no cartão
      </text>
    </svg>
  </span>
</html>

Step 2 – Add CSS

Copy and paste below code in your HTML editor between <style></style> tag.

<style>
@import url("https://fonts.googleapis.com/css2?family=Architects+Daughter&display=swap");
* {
  box-sizing: border-box;
}

body {
  background-image: #fff;
  background-repeat: no-repeat;
  background-size: cover;
  background-size-filter: grayScale(1);
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.merry-christmas img {
  width: 100px;
}

.card {
  -webkit-perspective: 1500px;
  -moz-perspective: 1500px;
  perspective: 1500px;
  position: absolute;
  left: calc(50% - 125px);
  top: calc(50% - 175px);
  -webkit-transition-property: -webkit-transform;
  -moz-transition-property: -moz-transform;
  transition-property: transform;
  -webkit-transition-duration: 1s;
  -moz-transition-duration: 1s;
  transition-duration: 1s;
  -webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  -moz-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  -webkit-transition-delay: initial;
  -moz-transition-delay: initial;
  transition-delay: initial;
  -webkit-transform: rotate(-10deg) translate(0, 0);
  -moz-transform: rotate(-10deg) translate(0, 0);
  -ms-transform: rotate(-10deg) translate(0, 0);
  -o-transform: rotate(-10deg) translate(0, 0);
  transform: rotate(-10deg) translate(0, 0);
  -webkit-animation: cardIn 1s alternate cubic-bezier(0.87, -0.41, 0.19, 1.44);
  -moz-animation: cardIn 1s alternate cubic-bezier(0.87, -0.41, 0.19, 1.44);
  animation: cardIn 1s alternate cubic-bezier(0.87, -0.41, 0.19, 1.44);
}
@media (max-width: 767px) {
  .card {
    left: calc(50% - 115px);
    top: calc(50% - 164.5px);
  }
}
@media (max-width: 479px) {
  .card {
    left: calc(50% - 75px);
    top: calc(50% - 107px);
  }
}
.card:before {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  box-shadow: 0 0 500px #000;
  -webkit-transition: all 0.5s ease-in-out;
  -moz-transition: all 0.5s ease-in-out;
  transition: all 0.5s ease-in-out;
}
.card.is-opened {
  -webkit-transform: rotate(0deg) translate(125px, 0);
  -moz-transform: rotate(0deg) translate(125px, 0);
  -ms-transform: rotate(0deg) translate(125px, 0);
  -o-transform: rotate(0deg) translate(125px, 0);
  transform: rotate(0deg) translate(125px, 0);
}
@media (max-width: 767px) {
  .card.is-opened {
    -webkit-transform: rotate(0deg) translate(115px, 0);
    -moz-transform: rotate(0deg) translate(115px, 0);
    -ms-transform: rotate(0deg) translate(115px, 0);
    -o-transform: rotate(0deg) translate(115px, 0);
    transform: rotate(0deg) translate(115px, 0);
  }
}
@media (max-width: 479px) {
  .card.is-opened {
    -webkit-transform: rotate(0deg) translate(75px, 0);
    -moz-transform: rotate(0deg) translate(75px, 0);
    -ms-transform: rotate(0deg) translate(75px, 0);
    -o-transform: rotate(0deg) translate(75px, 0);
    transform: rotate(0deg) translate(75px, 0);
  }
}
.card.is-opened .cart-page-front {
  -webkit-transform: rotateY(-180deg);
  -moz-transform: rotateY(-180deg);
  -ms-transform: rotateY(-180deg);
  -o-transform: rotateY(-180deg);
  transform: rotateY(-180deg);
}

@keyframes cardIn {
  0% {
    opacity: 0;
    -webkit-transform: rotate(-10deg) translate(0, -100%);
    -moz-transform: rotate(-10deg) translate(0, -100%);
    -ms-transform: rotate(-10deg) translate(0, -100%);
    -o-transform: rotate(-10deg) translate(0, -100%);
    transform: rotate(-10deg) translate(0, -100%);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    -webkit-transform: rotate(-10deg) translate(0, 0);
    -moz-transform: rotate(-10deg) translate(0, 0);
    -ms-transform: rotate(-10deg) translate(0, 0);
    -o-transform: rotate(-10deg) translate(0, 0);
    transform: rotate(-10deg) translate(0, 0);
  }
}
.card,
.card-page {
  width: 250px;
  height: 350px;
}
@media (max-width: 767px) {
  .card,
  .card-page {
    width: 230px;
    height: 329px;
  }
}
@media (max-width: 479px) {
  .card,
  .card-page {
    width: 150px;
    height: 214px;
  }
}

.card-page {
  -webkit-transition: -webkit-transform 1s ease-in-out;
  -moz-transition: -moz-transform 1s ease-in-out;
  transition: transform 1s ease-in-out;
  cursor: pointer;
  position: absolute;
  outline: 1px solid transparent;
}

.cart-page-front {
  -webkit-transform-origin: 0 50% 0;
  -moz-transform-origin: 0 50% 0;
  -ms-transform-origin: 0 50% 0;
  -o-transform-origin: 0 50% 0;
  transform-origin: 0 50% 0;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  -ms-transform-style: preserve-3d;
  -o-transform-style: preserve-3d;
  transform-style: preserve-3d;
  -webkit-transform: rotateY(-20deg);
  -moz-transform: rotateY(-20deg);
  -ms-transform: rotateY(-20deg);
  -o-transform: rotateY(-20deg);
  transform: rotateY(-20deg);
  z-index: 2;
}

.cart-page-outside,
.cart-page-inside {
  position: absolute;
  -webkit-backface-visibility: hidden;
}

.cart-page-outside {
  border: 10px solid #fbfbfb;
  background: #1165ae
    url("https://www.dailyherald.com/storyimage/DA/20121223/news/312239999/EP/1/13/EP-312239999.jpg&updated=201212191340&MaxW=800&MaxH=800&noborder")
    no-repeat center;
  background-size: cover;
  width: 100%;
  height: 100%;
}
@media (max-width: 767px) {
  .cart-page-outside {
    border: 5px solid #fbfbfb;
  }
}

.cart-page-inside,
.cart-page-bottom {
  background-color: #f9f9f9;
  background-image: url("https://www.dropbox.com/s/8hw7guch8d151kg/pattern.png?raw=1");
  border: 20px solid #f9f9f9;
  display: -webkit-box;
  display: -moz-box;
  display: box;
  display: -webkit-flex;
  display: -moz-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
  -moz-box-pack: center;
  box-pack: center;
  -webkit-justify-content: center;
  -moz-justify-content: center;
  -ms-justify-content: center;
  -o-justify-content: center;
  justify-content: center;
  -ms-flex-pack: center;
  -webkit-box-align: center;
  -moz-box-align: center;
  box-align: center;
  -webkit-align-items: center;
  -moz-align-items: center;
  -ms-align-items: center;
  -o-align-items: center;
  align-items: center;
  -ms-flex-align: center;
  text-align: center;
}
@media (max-width: 767px) {
  .cart-page-inside,
  .cart-page-bottom {
    border: 10px solid #f9f9f9;
  }
}

.cart-page-inside {
  -webkit-transform: rotateY(-180deg);
  -moz-transform: rotateY(-180deg);
  -ms-transform: rotateY(-180deg);
  -o-transform: rotateY(-180deg);
  transform: rotateY(-180deg);
  border-right: none !important;
  background-position: 0px 80px;
}
@media (max-width: 767px) {
  .cart-page-inside {
    background-position: 0px 30px;
  }
}
@media (max-width: 479px) {
  .cart-page-inside {
    background-position: 0px 30px;
  }
}

.cart-page-bottom {
  z-index: 1;
  border-left: none !important;
  background-position: -22px 80px;
}
@media (max-width: 767px) {
  .cart-page-bottom {
    background-position: 85px 30px;
  }
}
@media (max-width: 479px) {
  .cart-page-bottom {
    background-position: 0px 30px;
  }
}
.cart-page-bottom .merry-christmas img {
  width: 200px;
  height: auto;
}
@media (max-width: 767px) {
  .cart-page-bottom .merry-christmas img {
    width: 150px;
  }
}
@media (max-width: 479px) {
  .cart-page-bottom .merry-christmas img {
    width: 150px;
  }
}

p {
  font-family: "Architects Daughter", cursive;
  font-size: 20px;
  line-height: 1.2em;
  padding: 15px;
  color: #3c4a85;
}
@media (max-width: 767px) {
  p {
    font-size: 14px;
  }
}
@media (max-width: 479px) {
  p {
    font-size: 14px;
  }
}

.click-text {
  font-size: 6px;
  font-family: "Architects Daughter", cursive;
}

.click-icon {
  position: absolute;
  left: 50%;
  -webkit-transform: translate(-50%, 0);
  -moz-transform: translate(-50%, 0);
  -ms-transform: translate(-50%, 0);
  -o-transform: translate(-50%, 0);
  transform: translate(-50%, 0);
  bottom: 20px;
  -webkit-animation: iconAnimation 1s infinite alternate ease-in-out;
  -moz-animation: iconAnimation 1s infinite alternate ease-in-out;
  animation: iconAnimation 1s infinite alternate ease-in-out;
  -webkit-transition: opacity 0.5s ease-in-out;
  -moz-transition: opacity 0.5s ease-in-out;
  transition: opacity 0.5s ease-in-out;
  opacity: 1;
}
.click-icon svg {
  width: 96px;
  height: 96px;
}
@media (max-width: 767px) {
  .click-icon svg {
    width: 72px;
    height: 72px;
  }
}
@media (max-width: 479px) {
  .click-icon svg {
    width: 48px;
    height: 48px;
  }
}
.click-icon.is-hidden {
  opacity: 0;
}

@keyframes iconAnimation {
  0% {
    -webkit-transform: translate(-50%, 0);
    -moz-transform: translate(-50%, 0);
    -ms-transform: translate(-50%, 0);
    -o-transform: translate(-50%, 0);
    transform: translate(-50%, 0);
  }
  100% {
    -webkit-transform: translate(-50%, 10px);
    -moz-transform: translate(-50%, 10px);
    -ms-transform: translate(-50%, 10px);
    -o-transform: translate(-50%, 10px);
    transform: translate(-50%, 10px);
  }
}
</style>

Step 3 – Add JavaScript

And also copy and paste below JavaScript code between <script></script> tag.

<script>
const elemCard = document.querySelector("div.card");
const elemClickIcon = document.querySelector("span.click-icon");

elemCard.addEventListener("click", function () {
  elemCard.classList.toggle("is-opened");
  elemClickIcon.classList.toggle("is-hidden");
});

</script>

At the end we will have something like this. You can change fonts, colors, backgrounds and all things that you want.Enjoy it.

Before

how to create a Christmas Card using HTML CSS JS

After

how to create a Christmas Card using HTML CSS JS

Video Tutorial

Please watch this video to better understand this tutorial and don’t forget to subscribe to our channel.


Help others to find out about this article on Social Media sites. If you have any doubt or any problem, don’t hesitate to contact us. Thereafter we will be able to help you and also make sure you bookmark our site on your browser.

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button