☀Everything Automotive, Tested & Explained Stories

Create Your Own Wheel of Fortune Spinner

By

Are you looking to add a fun and interactive element to your website or blog? Why not create your own Wheel of Fortune spinner? This engaging tool can be used for games, contests, surveys, or just for fun. Let's dive into a step-by-step guide on how to make a Wheel of Fortune spinner using HTML, CSS, and JavaScript.

Before we start, ensure you have a basic understanding of these web development languages. If you're new to them, don't worry - we'll explain each step in detail. Now, let's spin the wheel and get started!

Setting Up the Basic Structure

The first step in creating your Wheel of Fortune spinner is setting up the basic HTML structure. We'll create a div for the spinner and a button to spin it.

a hand holding a colorful spinning wheel on top of a wooden stand next to a potted plant
a hand holding a colorful spinning wheel on top of a wooden stand next to a potted plant
an image of a fake wheel of fortune
an image of a fake wheel of fortune
How to Make an Halloween Wheel of Fortune Drinking Game Prop PART I
How to Make an Halloween Wheel of Fortune Drinking Game Prop PART I

Here's the basic HTML structure:

<div id="wheel"></div>
<button id="spin">Spin</button>

Creating the Spinner Style with CSS

Now, let's style our spinner using CSS. We'll give it a wheel shape, add some colors, and make it interactive.

DIY Spin Wheel Game 🎡 (Win Surprises!)
DIY Spin Wheel Game 🎡 (Win Surprises!)
Fun Spinning Wheel/Wheel of Fortune
Fun Spinning Wheel/Wheel of Fortune
How to Make an Halloween Wheel of Fortune Drinking Game Prop PART I
How to Make an Halloween Wheel of Fortune Drinking Game Prop PART I

Add the following CSS to your stylesheet:

.wheel {
  border: 1px solid #ccc;
  border-radius: 50%;
  width: 200px;
  height: 200px;
  position: relative;
  cursor: pointer;
}

 Whitehead {
  width: 50%;
  padding: 20px 0;
  text-align: center;
  position: absolute;
  top: 50%;
  transform-origin: 100% 50%;
  color: #fff;
  font-size: 18px;
}

Spinning the Wheel with JavaScript

The final step is to make the wheel spin when the user clicks the button. We'll use JavaScript to achieve this.

Add the following JavaScript code to your project:

Randomised Spinner Wheel - Audience Engagement in 1 Click​ | AhaSlides
Randomised Spinner Wheel - Audience Engagement in 1 Click​ | AhaSlides
Printable Blank Spinner Wheel Templates [PDF Included]
Printable Blank Spinner Wheel Templates [PDF Included]
How We Made Wheel of Fortune From Cardboard
How We Made Wheel of Fortune From Cardboard
How To Make Spinning Wheel With Cardboard | How To Make a Spinning Wheel DIY
How To Make Spinning Wheel With Cardboard | How To Make a Spinning Wheel DIY
Spin the Wheel – Free Wheel Spinner & Random Wheel Generator | Custom Picker Wheel
Spin the Wheel – Free Wheel Spinner & Random Wheel Generator | Custom Picker Wheel
Free Spinner Wheel Templates
Free Spinner Wheel Templates
const spinWheel = document.getElementById('wheel');
const spinButton = document.getElementById('spin');

spinButton.addEventListener('click', () => {
  spinWheel.style.transform = 'rotate(' + Math.random() * 360 + 'deg)';
});

Adding Sections and Prizes to the Wheel

So far, we have a spinning wheel, but it's not very interesting yet. Let's add sections and prizes to it.

First, update your HTML to include sections with prizes:

<div id="wheel">
  <div class="section enlarge" data-prize="Grand Prize">Grand Prize</div>
  <div class="section" data-prize="Prize 1">Prize 1</div>
  <div class="section" data-prize="Prize 2">Prize 2</div>
  <div class="section" data-prize="Prize 3">Prize 3</div>
  <div class="section" data-prize="Prize 4">Prize 4</div>
</div>

Randomizing the Spins

Currently, the wheel spins to a random degree each time, but it always lands on the same section. To make it truly random, we need to calculate the degree for each section and set that as the final spinning degree.

How to Make a Prize Wheel (with Pictures) - wikiHow
How to Make a Prize Wheel (with Pictures) - wikiHow
Free online spinner wheel of fortune for quick decision making
Free online spinner wheel of fortune for quick decision making
Printable Blank Spinner Wheel (1-4) Templates
Printable Blank Spinner Wheel (1-4) Templates
a hand is pointing at a spin to win card
a hand is pointing at a spin to win card

Update your JavaScript code as follows:

const spinButton = document.getElementById('spin');

// Get all sections
const sections = document.querySelectorAll('.section');

spinButton.addEventListener('click', () => {
  const randomPrize = sections[Math.floor(Math.random() * sections.length)].getAttribute('data-prize');
  alert('You won ' + randomPrize + '!');

  // Calculate the final spinning degree
  const degree = Math.floor(Math.random() * 360);
  spinWheel.style.transform = 'rotate(' + degree + 'deg)';
});

Now, when you click the "Spin" button, the wheel will spin to a random section, and you'll see an alert with your prize.

Congratulations, you've just created your own Wheel of Fortune spinner! This interactive tool can now be used to engage your website visitors. From here, you can customize the design, add more sections, or even make it responsive for different screen sizes.

Happy spinning!