Build an Availability Table - Build an Availability Table

Tell us what’s happening:

  1. You should use two color-stops (expressed in percentage) to make the transition from one color to the following color a hard line for your #legend-gradient. Remember to use your --color# variables

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="styles.css" rel="stylesheet">
    <title>Availability Table</title>
</head>

<body>
  <table>
    <tr>
      <th>Time</th>
      <th>Monday</th>
      <th>Tuesday</th>
      <th>Wednesday</th>
    </tr>
    <tr class="sharp">
      <th class="time">9 am</th>
      <td class="available-2"></td>
      <td class="available-4"></td>
      <td class="available-0"></td>
    </tr>
    <tr class="half">
      <th class="time">12 pm</th>
      <td class="available-1"></td>
      <td class="available-5"></td>
      <td class="available-3"></td>
    </tr>
    <tr class="sharp">
      <th class="time">3 pm</th>
      <td class="available-0"></td>
      <td class="available-3"></td>
      <td class="available-5"></td>
    </tr>
    <tr class="half">
      <th class="time">6 pm</th>
      <td class="available-2"></td>
      <td class="available-4"></td>
      <td class="available-0"></td>
    </tr>
  </table>

  <div id="legend">
    <span>Availability</span>
    <div id="legend-gradient"></div>
  </div>
</body>

</html>
/* file: styles.css */
:root {
  --color0: #d9d9d9;
  --color1: #a8d5ff;
  --color2: #74b9ff;
  --color3: #0984e8;
  --color4: #6c5ce7;
  --color5: #341f97;

  --solid-border: 3px solid black;
  --dashed-border: 3px dashed black;
}

body {
  padding: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
}

th, td {
  text-align: center;
  padding: 15px;
  border-right: 1px solid #000;
}

.sharp td {
  border-bottom: var(--solid-border);
}

.half td {
  border-bottom: var(--dashed-border);
}

/* time column */
.time {
  font-weight: bold;
}

/* coloring availability */
.available-0 { background-color: var(--color0); }
.available-1 { background-color: var(--color1); }
.available-2 { background-color: var(--color2); }
.available-3 { background-color: var(--color3); }
.available-4 { background-color: var(--color4); }
.available-5 { background-color: var(--color5); }

/*legend*/
#legend span {
  font-weight: bold;
  margin-bottom: 3rem;
}

#legend-gradient {
  width: 100%;
  height: 20px;

  background-image: linear-gradient(
    to right,
    var(--color0) 0%, var(--color0) 16.6%,
    var(--color1) 16.6%, var(--color1) 33.2%,
    var(--color2) 33.2%, var(--color2) 49.8%,
    var(--color3) 49.8%, var(--color3) 66.4%,
    var(--color4) 66.4%, var(--color4) 83%,
    var(--color5) 83%, var(--color5) 100%
  );
}

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36

Challenge Information:

Build an Availability Table - Build an Availability Table

Please refer to this reference for an example of how that is done:

https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient#gradient_with_multi-position_color-stops

Note that the percentages should be integers.

1 Like

Thanks for the help am all done