CSS

CSS changes how the page looks. It controls colors, shapes, sizes, and glows.

How to Write CSS

Every CSS rule is written the same way — a selector, curly braces, and a property with a value that ends in a semicolon.

button ↑ selector — matches every <button> on the page
{ ↑ opening curly brace
border-radius: 50%; ↑ property: value;
} ↑ closing curly brace

Every selector looks like this:

div {
    property: value;
    property: value;
}

button {
    property: value;
    property: value;
}

Helpful CSS Properties

Here are the properties we used to build our ball, with an example of what each one actually does.

background

background: radial-gradient(circle, #7ec2ff, #2f8eff);

Sets the background of an element — a solid color, or a gradient like the glow inside our ball.

background-image

background-image: url("...");

Sets a picture as the background of an element, instead of a solid color or gradient.

border

border: 4px dashed dodgerblue;

Draws a line around the edge of an element. It can be solid, dashed, dotted, and more.

border-radius

border-radius: 50%;

Rounds the corners of a box. At 50%, a square div turns into a perfect circle — that's how our ball (and the answer window inside it) become round.

→

box-shadow

box-shadow: 0 0 20px 6px dodgerblue;

Adds a shadow, or a glow, around an element. That's what makes the answer window in our ball light up.

color

color: #7ec2ff;

Sets the color of text.

Not likely

font-size

font-size: 48px;

Sets how big text is.

8 → 8

width / height

width: 180px; height: 180px;

Sets how big a box is — that's how we control the size of our ball.

→

Add styles to your game

Here's our ball with CSS added. Open the Preview tab — it's round and glowing now, but clicking it doesn't do anything yet. That's JavaScript's job. Add everything in green — check all three tabs.

🔒

Ask Arissa for the password after you tried yourself.

🔒

Ask Arissa for the password after you tried yourself.