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

84 lines
1.9 KiB
Markdown
Raw Normal View History

---
id: 5f356ed656a336993abd9f7c
title: Passo 26
challengeType: 0
dashedName: step-26
---
# --description--
Em seguida, centralize a `div` horizontalmente. Você pode fazer isso definindo as propriedades `margin-left` e `margin-right` como `auto`. Pense na margem como um espaço invisível em torno de um elemento. Usando essas duas propriedades de margem, centralize o elemento `div` dentro do elemento `body`.
# --hints--
Você deve definir a propriedade `margin-left` para `auto`.
```js
const hasMargin = new __helpers.CSSHelp(document).getCSSRules().some(x => x.style['margin-left'] === 'auto');
assert(hasMargin);
```
Você deve definir a propriedade `margin-right` para `auto`.
```js
const hasMargin = new __helpers.CSSHelp(document).getCSSRules().some(x => x.style['margin-right'] === 'auto');
assert(hasMargin);
```
Você deve definir as propriedades `margin-left` e `margin-right` do elemento `div` para `auto`.
```js
const divMarginRight = new __helpers.CSSHelp(document).getStyle('div')?.getPropertyValue('margin-right');
const divMarginLeft = new __helpers.CSSHelp(document).getStyle('div')?.getPropertyValue('margin-left');
assert(divMarginRight === 'auto');
assert(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>
<main>
<header>
<h1>CAMPER CAFE</h1>
<p>Est. 2020</p>
</header>
<section>
<h2>Coffee</h2>
</section>
</main>
</div>
</body>
</html>
```
```css
body {
/*
background-color: burlywood;
*/
}
h1, h2, p {
text-align: center;
}
--fcc-editable-region--
div {
width: 80%;
background-color: burlywood;
}
--fcc-editable-region--
```