ADVERTISEMENT

Ice Cream Maker using HTML, CSS & JavaScript

Telegram Group Join Now

ADVERTISEMENT

Ice Cream Maker using HTML, CSS & JavaScript

Hello, today we’re going to learn how to use HTML, CSS & JavaScript to create a Ice Cream Maker. By following these instructions, you can simply make this Ice Cream Maker in HTML, CSS & JavaScript. Simply by adhering to the procedures mentioned below, you will be able to develop this amazing Ice Cream Maker.

ADVERTISEMENT

ADVERTISEMENT

Custom Icecream Maker Javascript

Project Description

Step 1
The HTML (Hypertext Markup Language) will help us to create the structure for the list with some necessary attributes and elements to make Ice Cream Maker Project.

ADVERTISEMENT

Step 2
Then we will use CSS (Cascading Stylesheet) which will help us to style or design the project with suitable padding and alignment in the Ice Cream Maker Project.

ADVERTISEMENT

Step 3
At last we will use JS (JavaScript) which will add a logic to make the Ice Cream Maker Project functioning from the user end.

I hope you have got an idea about the project.

Restaurant Website Using HTML and CSS

ADVERTISEMENT

HTML Code for Ice Cream Maker

<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Customize Icecrean</title>
    <!-- Google Fonts -->
    <link
      href="https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap"
      rel="stylesheet"
    />
    <!-- Stylesheet -->
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div class="wrapper">
      <div class="container">
        <div class="scoop1"></div>
        <div class="scoop2"></div>
        <div class="scoop3"></div>
        <div class="bowl">
          <div class="base"></div>
        </div>
      </div>
      <div class="btns">
        <button id="btn-scoop1">Scoop 1</button>
        <button id="btn-scoop2">Scoop 2</button>
        <button id="btn-scoop3">Scoop 3</button>
        <button id="btn-topping1">Topping 1</button>
        <button id="btn-topping2">Topping 2</button>
      </div>
    </div>
    <!-- Script -->
    <script src="script.js"></script>
  </body>
</html>

First we’ll start with creating the structure of the Ice Cream Maker project for that as you can see the above code we have used all the necessary elements & attributes to setup the structure. Let us know code the CSS part to add styling and aligned the tags.

CSS Code for Ice Cream Maker

body {
  padding: 0;
  margin: 0;
  background-color: #dcacfe;
}
.wrapper {
  width: 350px;
  position: absolute;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 50%;
  padding: 30px;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}
.container {
  width: 100%;
  height: 350px;
  position: relative;
}
.bowl {
  width: 230px;
  height: 90px;
  background-color: #d9f0fe;
  position: absolute;
  margin: auto;
  left: 0;
  right: 0;
  bottom: 90px;
  border-radius: 0 0 150px 150px;
}
.bowl:before {
  content: "";
  position: absolute;
  height: 20px;
  width: 110%;
  background-color: #afddfa;
  left: -5%;
  border-radius: 20px;
}
.base {
  height: 40px;
  width: 20px;
  background-color: #afddfa;
  position: absolute;
  margin: auto;
  left: 0;
  right: 0;
  top: 90px;
}
.base:after {
  content: "";
  position: absolute;
  height: 40px;
  width: 120px;
  background-color: #d9f0fe;
  left: -50px;
  top: 30px;
  border-radius: 50px 50px 0 0;
}
.scoop1 {
  height: 130px;
  width: 130px;
  background-color: #f45c96;
  border-radius: 50%;
  position: absolute;
  background-size: 40px 150px;
  background-image: radial-gradient(
    circle at 20px 12px,
    #f8bd3d 25px,
    transparent 25px
  );
  top: 20px;
  left: 108px;
}
.scoop2 {
  height: 130px;
  width: 130px;
  background-color: #badc58;
  border-radius: 50%;
  position: absolute;
  top: 100px;
  right: 70px;
}
.scoop3 {
  height: 130px;
  width: 130px;
  background-color: #f58619;
  border-radius: 50%;
  position: absolute;
  top: 100px;
  left: 70px;
  background-size: 25px 80px;
  background-image: radial-gradient(
    circle at 12.5px 17px,
    #5c0003 20px,
    transparent 21px
  );
}
.btns {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
  padding-top: 15px;
  border-top: 2px dashed #404080;
}
.btns button {
  width: 150px;
  padding: 12px 0;
  border-radius: 20px;
  margin-top: 20px;
  border: none;
  outline: none;
  background-color: #c174f8;
  color: #ffffff;
  cursor: pointer;
}

Second comes the CSS code, which is mentioned above in that we have styled for the structure we have padded as well as aligned the Ice Cream Maker project so that it is properly situated and doesn’t get messy with suitable CSS elements. Now we have created the structure using HTML and styled the webpage using CSS its time to add the functionality using JavaScript in this project.

JavaScript Code for Ice Cream Maker

Ecommerce Website Using HTML, CSS, & JavaScript (Source Code)

ADVERTISEMENT

let scoop1 = document.querySelector(".scoop1");
let scoop2 = document.querySelector(".scoop2");
let scoop3 = document.querySelector(".scoop3");

let btnScoop1 = document.getElementById("btn-scoop1");
let btnScoop2 = document.getElementById("btn-scoop2");
let btnScoop3 = document.getElementById("btn-scoop3");
let btnTopping1 = document.getElementById("btn-topping1");
let btnTopping2 = document.getElementById("btn-topping2");

let colors = ["#f45c96", "#f8bd3d", "#badc58", "#5c0003", "#f58619", "#ebab70"];

let counter1 = 0;
let counter2 = 0;
let counter3 = 0;
let counter4 = 0;
let counter5 = 0;

function setCounterValue(counter) {
  return counter < colors.length - 1 ? counter + 1 : 0;
}

btnScoop1.addEventListener("click", () => {
  scoop1.style.backgroundColor = colors[counter1];
  counter1 = setCounterValue(counter1);
});
btnScoop2.addEventListener("click", () => {
  scoop2.style.backgroundColor = colors[counter2];
  counter2 = setCounterValue(counter2);
});
btnScoop3.addEventListener("click", () => {
  scoop3.style.backgroundColor = colors[counter3];
  counter3 = setCounterValue(counter3);
});
btnTopping1.addEventListener("click", () => {
  scoop1.style.backgroundImage = `radial-gradient(circle at 20px 18px, ${colors[counter4]} 25px, transparent 25px)`;
  counter4 = setCounterValue(counter4);
});
btnTopping2.addEventListener("click", () => {
  scoop3.style.backgroundImage = `radial-gradient(circle at 12.5px 17px, ${colors[counter5]} 20px, transparent 21px)`;
  counter5 = setCounterValue(counter5);
});

Last stage of the project the JavaScript in which we have added the logical and coded as per the requirement with some conditions. We have defined the event listener function to make the ice cream project functioning from the user side and add the toping & scoops as per the user action. Let us see the Final Output of the project Ice Cream Maker using HTML, CSS & JavaScript.

ADVERTISEMENT

Output

 

Live Preview of Ice Cream Maker using HTML, CSS & JavaScript (Source Code)

See the Pen
Ice cream Maker
by Harsh Sawant (@harshh9)
on CodePen.

We have Successfully created our Ice Cream Maker using HTML, CSS & JavaScript. You can use this project for your personal needs and the respective lines of code are given with the code pen link mentioned above.

If you find out this Blog helpful, then make sure to search code with random on google for Front End Projects with Source codes and make sure to Follow the Code with Random Instagram page.

ADVERTISEMENT

Code Idea – codingartist

ADVERTISEMENT

Written By – Harsh Sawant

ADVERTISEMENT

Code By – @harshh9

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Telegram Group Join Now

Share on:

Leave a Comment

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT