freeCodeCamp/curriculum/challenges/italian/14-responsive-web-design-22/learn-basic-css-by-building.../5f344f9c805cd193c33d829c.md

1.4 KiB

id title challengeType dashedName
5f344f9c805cd193c33d829c Step 12 0 step-12

--description--

Puoi aggiungere uno stile a un elemento specificandolo nell'elemento style e impostando una proprietà in questo modo:

elemento {
 proprietà: valore;
}

Centra l'elemento h1 assegnando alla proprietà text-align il valore center.

--hints--

Dovresti avere un selettore h1 nell'elemento style.

const hasSelector = new __helpers.CSSHelp(document).getStyle('h1');
assert(hasSelector);

La proprietà text-align dovrebbe avere il valore center.

const hasTextAlign = new __helpers.CSSHelp(document).getCSSRules().some(x => x.style['text-align'] === 'center');
assert(hasTextAlign);

Il selettore h1 dovrebbe assegnare alla proprietà text-align il valore center.

const h1TextAlign = new __helpers.CSSHelp(document).getStyle('h1')?.getPropertyValue('text-align');
assert(h1TextAlign === 'center');

--seed--

--seed-contents--

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Cafe Menu</title>
--fcc-editable-region--
    <style>
    </style>
--fcc-editable-region--
  </head>
  <body>
    <main>
      <header>
        <h1>CAMPER CAFE</h1>
        <p>Est. 2020</p>
      </header>
      <section>
        <h2>Coffee</h2>
      </section>
    </main>
  </body>
</html>