freeCodeCamp/curriculum/challenges/italian/14-responsive-web-design-22/learn-more-about-css-pseudo.../61fd75ea7f663457612dba02.md

3.1 KiB

id title challengeType dashedName
61fd75ea7f663457612dba02 Step 11 0 step-11

--description--

All'interno di ciascuno dei nuovi elementi th, annida un elemento span con l'attributo class del valore di sr-only year. Assegna loro il seguente testo (in ordine): 2019, 2020e 2021.

Dai al terzo elemento th l'attributo class con il valore current.

Lascia vuoto l'elemento td. Questo elemento esiste solo per garantire che la tabella abbia un layout a quattro colonne e associare le intestazioni alle colonne corrette.

--hints--

Ognuno degli elementi th dovrebbe avere un elemento span.

const ths = [...document.querySelectorAll('th')];
ths?.forEach(th => {
  assert(th?.children?.length === 1);
  assert(th?.children?.[0]?.localName === 'span');
});

Ognuno dei nuovi elementi span dovrebbe avere l'attributo class con il valore sr-only year.

const ths = [...document.querySelectorAll('th')];
ths?.forEach(th => {
  assert(th?.children?.[0]?.classList?.contains('sr-only'));
  assert(th?.children?.[0]?.classList?.contains('year'));
});

Il primo elemento span dovrebbe avere il testo 2019.

assert(document.querySelectorAll('th')?.[0]?.children?.[0]?.textContent === '2019');

Il secondo elemento span dovrebbe avere il testo 2020.

assert(document.querySelectorAll('th')?.[1]?.children?.[0]?.textContent === '2020');

Il terzo elemento span dovrebbe avere il testo 2021.

assert(document.querySelectorAll('th')?.[2]?.children?.[0]?.textContent === '2021');

Il terzo elemento th dovrebbe avere l'attributo class con il valore current.

assert(document.querySelector('table')?.querySelectorAll('th')?.[2]?.classList?.contains('current'));

L'elemento td dovrebbe essere vuoto.

assert(document.querySelector('table')?.querySelectorAll('td')?.[0]?.textContent === '');
assert(document.querySelector('table')?.querySelectorAll('td')?.[0]?.children?.length === 0);

--seed--

--seed-contents--

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Balance Sheet</title>
    <link rel="stylesheet" href="./styles.css">
  </head>
  <body>
    <main>
      <section>
        <h1>
          <span class="flex">
            <span>AcmeWidgetCorp</span>
            <span>Balance Sheet</span>
          </span>
        </h1>
        <div id="years" aria-hidden="true">
          <span class="year">2019</span>
          <span class="year">2020</span>
          <span class="year">2021</span>
        </div>
        <div class="table-wrap">
          <table>
            <caption>Assets</caption>
--fcc-editable-region--
            <thead>
              <tr>
                <td></td>
                <th></th>
                <th></th>
                <th></th>
              </tr>
            </thead>
--fcc-editable-region--
            <tbody>
            </tbody>
          </table>
          <table>
          </table>
          <table>
          </table>
        </div>
      </section>
    </main>
  </body>
</html>