• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

The Coding Couple

Pair programming is a lifetime commitment.

  • Home
  • Categories
    • Arduino
    • JavaScript
    • Python
    • Raspberry Pi
  • About Us
    • Privacy Policy
  • Contact

Pokéball Single DIV CSS Drawing | Tutorial

May 7, 2024 by Ashley

Pokéball Single Div CSS drawing
Pokéball Single Div CSS drawing

In this blog post, I will walk you through how I created a 2D Pokéball using a single div and a little bit of CSS. Like my previous single div drawing tutorial, I will be picking up right where I left off in my CSS Magic with a Single DIV tutorial.

In that tutorial, I covered the basic building blocks of single div drawings:

  • pseudo-elements
  • box-shadows
  • background and gradients
  • …and more

Now, let’s get started!

Drawing a Pokéball with CSS

When tackling a single div drawing, it is helpful to break down the object your intend to draw into basic shapes. In the case of the Pokéball, most of our work it cut out for us because the primary shape is a circle. There is:

  • a circle for the main shape of the Pokéball
  • a circle for the Pokéball button
  • semi-circles for the top and bottom portion of the Pokéball
  • a rectangle band around the center of the Pokéball

Step 1: Create the basic shape of the Pokéball

With our basic shapes in mind, it’s time to draw them. Let’s start off with some CSS basic boilerplate and a div for our drawing.

<div></div>
body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: white;
}

div {
  height: 50vmin;
  width: 50vmin;
}

Now, let’s update the div style so it takes the shape of a circle. We can do this by updating the border-radius property to 50%. Set the background-color of the div to red to represent part of the Pokéball.

div {
  height: 50vmin;
  width: 50vmin;
  border-radius: 50%;
  background-color: red;
}
Circular div with the border-radius property
Circular div with the border-radius property

Step 2: Add a border around the circle

Add a solid black border around the circle to help it stand out more.

div {
  height: 50vmin;
  width: 50vmin;
  border-radius: 50%;
  background-color: red;
  border: 3.75vmin solid black;
}
Circle surrounded by solid black border
Circle surrounded by solid black border

Step 3: Draw the semi-circles and middle band of the Pokéball

Next up, let’s tackle the red and white semi-circles for the top and bottom portions, well as the black mid-section of the Pokéball. To do this, let’s use a linear gradient.

div {
  height: 50vmin;
  width: 50vmin;
  border-radius: 50%;
  border: 3.75vmin solid black;
  background-image: linear-gradient(red 46%, black 46%, black 54%, white 54%);
}
Circular div with a linear gradient
Circular div with a linear gradient

The addition of the linear gradient removes the need for background-color property setting, so let’s remove that line.

Step 4: Draw a circle for the Pokéball button

Finally, we need to draw the button. To do this, let’s use another gradient: the radial-gradient.

div {
  height: 50vmin;
  width: 50vmin;
  border-radius: 50%;
  border: 3.75vmin solid black;
  background-image:
    radial-gradient(white 20%, white 20%, black 20%, black 30%, transparent 30%, transparent), 
    linear-gradient(red 46%, black 46%, black 54%, white 54%);
}

A couple things worth mentioning:

  • You can add multiple gradients to the background image property. The first item it the list is the top most item.
  • Use commas to separate the different gradients. I made the mistake of adding a semicolon and was stumped on why things weren’t drawing like I expected. Don’t make my blunder!
Pokeball single div CSS drawing
Pokeball single div CSS drawing

Codepen Example

Play around with the Pokéball in Codepen!

See the Pen Single Div Pokéball Drawing by Ashley Grenon (@townsean) on CodePen.

Ashley
~ Ashley

LET’S BE FRIENDS!

  • Instagram: @thecodingcouple
  • X: @thecodingcouple
  • GitHub: @thecodingcouple
  • Other Blog Posts

Related Posts

  • CSS Magic with a Single DivCSS Magic with a Single Div
  • Pokémon Color Picker | A web app built with HTML/CSS + JavaScriptPokémon Color Picker | A web app built with HTML/CSS + JavaScript
  • NESPi Raspberry Pi Case (RetroFlag) Mini ReviewNESPi Raspberry Pi Case (RetroFlag) Mini Review
  • AdaBox 005: Break for Pi | Adafruit Subscription BoxAdaBox 005: Break for Pi | Adafruit Subscription Box
  • I made a Sphere-O-Bot (An EggBot Mod)I made a Sphere-O-Bot (An EggBot Mod)
  • Southeastern Technical Conferences & Events (2016 Edition)Southeastern Technical Conferences & Events (2016 Edition)

Filed Under: HTML and CSS Tagged With: css, gradients, pokéball, pokemon, single div, single div drawing

Previous Post: « Error: [🍍]: “getActivePinia()” was called but there was no active Pinia
Next Post: Pokémon Color Picker | A web app built with HTML/CSS + JavaScript »

Primary Sidebar

Social Media

  • GitHub
  • Instagram
  • Twitter
  • YouTube

Recent Posts

  • Pokémon Color Picker | A web app built with HTML/CSS + JavaScript
  • Pokéball Single DIV CSS Drawing | Tutorial
  • Error: [🍍]: “getActivePinia()” was called but there was no active Pinia
  • Trijam #261 Game Jam Diary: One Wrong Move
  • Using WSL on Corporate VPN

Recent Comments

  • Lizzy on Creation Crate Month 2: An Arduino Powered Memory Game
  • Ashley Grenon on Creation Crate Month 2: An Arduino Powered Memory Game
  • Lizzy on Creation Crate Month 2: An Arduino Powered Memory Game
  • kelly on Creation Crate Month 2: An Arduino Powered Memory Game
  • Ashley on Creation Crate Month 3: An Arduino Powered Distance Detector

Follow us on Instagram!

This error message is only visible to WordPress admins

Error: No feed found.

Please go to the Instagram Feed settings page to create a feed.

Categories

  • Arduino
  • Conferences
  • Debugging
  • Game Jams
  • HTML and CSS
  • JavaScript
  • Programming Languages
  • Python
  • Raspberry Pi
  • Today I Learned

Archives

  • May 2024
  • April 2024
  • March 2024
  • May 2022
  • December 2021
  • May 2021
  • March 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • June 2019
  • April 2019
  • September 2017
  • April 2017
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • April 2015
  • January 2015

Tags

adafruit arduino brackets c# code smell codestock coding standards conventions creation crate debugging developer devspace electronics es6 es2015 game development game jam gotcha hackathon hoisting html html5 javascript led naming conventions nintendo phaser pluralsight pokemon programmer python raspberry pi retro retropie scope self improvement single div single div drawing subscription box TIL today I learned troubleshooting vue vuejs windbg

Footer

About Us

We are the Coding Couple.  Two people who met in college and decided they wanted to pair program for the rest of their ...

Read More »

Most Recent Posts

Pokémon Color Picker | A web app built with HTML/CSS + JavaScript

Pokéball Single DIV CSS Drawing | Tutorial

Error: [🍍]: “getActivePinia()” was called but there was no active Pinia

Trijam #261 Game Jam Diary: One Wrong Move

Social Media

  • GitHub
  • Instagram
  • Twitter
  • YouTube

Copyright Notice

© The Coding Couple, 2015 – 2023. Excerpts and links may be used, provided that full and clear credit is given to The Coding Couple with appropriate and specific direction to the original content.

Copyright © 2025 · Foodie Pro Theme by Shay Bocks · Built on the Genesis Framework · Powered by WordPress