Back to Freecodecamp

Step 14

curriculum/challenges/english/blocks/workshop-game-settings-panel/68e9a834dfef752dc35f6f90.md

latest2.6 KB
Original Source

--description--

Now that your checkboxes change color when the user clicks them, you are going to apply some styling to make it a little more obvious that the checkbox has been selected.

CSS pseudo-classes can be chained. You can add one pseudo-class or pseudo-element after another to target elements that meet multiple conditions.

Create a new selector for input[type="checkbox"]. Add the :checked pseudo-class followed by the ::after pseudo-element. This allows you to add a visual indicator when the checkbox is checked.

Next, add content with the value of "✓".

--hints--

You should have a combined type selector with a pseudo-class selector and pseudo-element selector of input[type="checkbox"]:checked::after.

js
assert.exists(new __helpers.CSSHelp(document).getStyle('input[type="checkbox"]:checked::after'));

You should add a content property to your combined type selector with a pseudo-class selector and pseudo-element selector of input[type="checkbox"]:checked::after.

js
assert.isNotEmpty(new __helpers.CSSHelp(document).getStyle('input[type="checkbox"]:checked::after')?.content);

You should have a content property with a value of "✓".

js
assert.strictEqual(new __helpers.CSSHelp(document).getStyle('input[type="checkbox"]:checked::after')?.content, '"✓"');

--seed--

--seed-contents--

html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Game Settings Panel</title>
    <link rel="stylesheet" href="styles.css" />
  </head>
  <body>
    <div class="settings-card">
      <h1>Game Settings</h1>
      <label> <input type="checkbox" />Sound Effects</label>
      <label> <input type="checkbox" />Background Music</label>
      <label> <input type="checkbox" />Hard Mode</label>
      <label> <input type="checkbox" />Haptic feedback</label>
    </div>
  </body>
</html>
css
body {
  height: 100vh;
  background-color: #f0f0f0;
  text-align: center;
}

.settings-card {
  max-width: 250px;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  margin: auto;
  text-align: left;
}

h1 {
  text-align: center;
}

label {
  display: block;
  cursor: pointer;
  margin: 8px auto;
}

input[type='checkbox'] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  appearance: none;
  border: 2px solid #f1be32;
  border-radius: 4px;
  background-color: white;
  transition: all 0.3s;
  vertical-align: middle;
  margin-right: 15px;
}

input[type='checkbox']:checked {
  background-color: #f1be32;
  border-color: #e2a60d;
}

--fcc-editable-region--

--fcc-editable-region--