Back to Freecodecamp

Step 16

curriculum/challenges/english/blocks/learn-intermediate-css-by-building-a-cat-painting/6477062778c85972eb648030.md

latest2.2 KB
Original Source

--description--

You should now center the cat head.

Give the .cat-head element a position property set to absolute. Set a value of 0 for the right, left, top, bottom properties, then set its margin property on all sides to auto. That's one way to center an element vertically and horizontally using CSS positioning.

--hints--

Your .cat-head selector should have a position property set to absolute. Make sure you add a semicolon.

js
assert(new __helpers.CSSHelp(document)?.getStyle('.cat-head')?.position === 'absolute')

Your .cat-head selector should have a top property set to 0. Make sure you add a semicolon.

js
assert(new __helpers.CSSHelp(document)?.getStyle('.cat-head')?.top === '0px')

Your .cat-head selector should have a left property set to 0. Make sure you add a semicolon.

js
assert(new __helpers.CSSHelp(document)?.getStyle('.cat-head')?.left === '0px')

Your .cat-head selector should have a right property set to 0. Make sure you add a semicolon.

js
assert(new __helpers.CSSHelp(document)?.getStyle('.cat-head')?.right === '0px')

Your .cat-head selector should have a bottom property set to 0. Make sure you add a semicolon.

js
assert(new __helpers.CSSHelp(document)?.getStyle('.cat-head')?.bottom === '0px')

Your .cat-head selector should have a margin property set to auto. Make sure you add a semicolon.

js
assert(new __helpers.CSSHelp(document)?.getStyle('.cat-head')?.margin === 'auto')

--seed--

--seed-contents--

html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>fCC Cat Painting</title>
    <link rel="stylesheet" href="./styles.css">
</head>
<body>
    <main>
      <div class="cat-head"></div>
      <div class="box"></div>
    </main>
</body>
</html>
css
* {
  box-sizing: border-box;
}

body {
  background-color: #c9d2fc;
}

.cat-head {
--fcc-editable-region--
  position: sticky;
  top: 0;
--fcc-editable-region--
  background: linear-gradient(#5e5e5e 85%, #45454f 100%);
  width: 205px;
  height: 180px;
  border: 1px solid #000;
  border-radius: 46%;
}

.box {
  width: 400px;
  height: 600px;
  background-color: #000;
  position: absolute;
  left: 650px;
  top: 800px;
}