Back to Freecodecamp

Step 21

curriculum/challenges/english/blocks/workshop-cafe-menu/5f356ed656a336993abd9f7c.md

latest1.8 KB
Original Source

--description--

Next, you want to center the #menu horizontally. You can do this by setting its margin-left and margin-right properties to auto. Think of the margin as an invisible space around an element. Using these two margin properties, center the #menu element within the body element.

--hints--

You should set the margin-left property to auto.

js
const hasMargin = new __helpers.CSSHelp(document).getCSSRules().some(x => x.style['margin-left'] === 'auto');
assert.isTrue(hasMargin);

You should set the margin-right property to auto.

js
const hasMargin = new __helpers.CSSHelp(document).getCSSRules().some(x => x.style['margin-right'] === 'auto');
assert.isTrue(hasMargin);

You should set the margin-left and margin-right properties of your #menu to auto.

js
const divMarginRight = new __helpers.CSSHelp(document).getStyle('#menu')?.getPropertyValue('margin-right');
const divMarginLeft = new __helpers.CSSHelp(document).getStyle('#menu')?.getPropertyValue('margin-left');
assert.equal(divMarginRight, 'auto');
assert.equal(divMarginLeft, 'auto');

--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>Cafe Menu</title>
    <link href="styles.css" rel="stylesheet"/>
  </head>
  <body>
    <div id="menu">
      <main>
        <h1>CAMPER CAFE</h1>
        <p>Est. 2020</p>
        <section>
          <h2>Coffee</h2>
        </section>
      </main>
    </div>
  </body>
</html>
css
body {
  /*
  background-color: burlywood;
  */
}

h1, h2, p {
  text-align: center;
}

#menu {
  width: 80%;
  background-color: burlywood;
--fcc-editable-region--
  
--fcc-editable-region--
}