{
    "componentChunkName": "component---src-templates-challenges-classic-show-tsx",
    "path": "/learn/front-end-development/lab-moon-orbit/build-a-moon-orbit",
    "result": {"data":{"challengeNode":{"challenge":{"block":"lab-moon-orbit","demoType":"onClick","title":"Build a Moon Orbit","description":"<section id=\"description\">\n<p>In this lab, you will create a simple animation of the Moon's orbit around the Earth using HTML and CSS. The Earth will be at the center of the system, and the Moon will orbit around it.</p>\n<p><strong>Objective:</strong> Fulfill the user stories below and get all the tests to pass to complete the lab.</p>\n<p><strong>User Stories:</strong></p>\n<ol>\n<li>\n<p>You should align all the elements to the center of the page by setting the height to <code>100%</code> of the viewport and setting a flexbox layout in the <code>body</code> element.</p>\n</li>\n<li>\n<p>You should have a <code>div</code> with the class <code>space</code>.</p>\n</li>\n<li>\n<p>Inside the <code>.space</code> <code>div</code>, there should be two more <code>div</code> elements with the class <code>earth</code> and <code>orbit</code>, respectively, in order.</p>\n</li>\n<li>\n<p>Inside the <code>.orbit</code> <code>div</code>, there should be another <code>div</code> with the class <code>moon</code>.</p>\n</li>\n<li>\n<p>The <code>space</code> <code>div</code> should be centered on the page and have a width and height of <code>200px</code>.</p>\n</li>\n<li>\n<p>The <code>earth</code> <code>div</code> should use <code>absolute</code> positioning. Position the center of the <code>earth</code> <code>div</code> at the halfway point of its parent on both the vertical (top) and horizontal (left) axes. After that, shift the <code>earth</code> <code>div</code> back by half its own width and height, to center it within its parent, <code>.space</code>.</p>\n</li>\n<li>\n<p>The <code>earth</code> <code>div</code> should have a width and height of <code>100px</code>.</p>\n</li>\n<li>\n<p>The <code>orbit</code> <code>div</code> should have a width and height of <code>200px</code>.</p>\n</li>\n<li>\n<p>The <code>orbit</code> <code>div</code> should be positioned using <code>absolute</code> positioning. Its bottom right corner should be at the center of the <code>space</code> <code>div</code> using a <code>transform</code> property that shifts it by <code>-50%</code> on both the vertical and horizontal axes.</p>\n</li>\n<li>\n<p>The orbit path for the moon around the Earth should be a circle.</p>\n</li>\n<li>\n<p>The moon <code>div</code> should be positioned using <code>absolute</code> positioning and have a width and height of <code>30px</code>. The moon <code>div</code> should position itself at the top of the <code>orbit</code> <code>div</code> and be centered horizontally.</p>\n</li>\n<li>\n<p>You should further adjust the horizontal positioning of the <code>moon</code> by moving the element to the left by half of its width.</p>\n</li>\n<li>\n<p>Your <code>.earth</code> and <code>.moon</code> <code>div</code> elements should have a background color and a <code>border-radius</code> of <code>50%</code> to make them look like planets.</p>\n</li>\n<li>\n<p>You should define a <code>@keyframes orbit</code> animation that rotates the <code>.orbit</code> element 360 degrees around its center. You should apply this animation to the <code>.orbit</code> element with a duration of <code>5</code> seconds, a linear timing function, and infinite iterations.</p>\n</li>\n</ol>\n<p><strong>Note:</strong> Be sure to link your stylesheet in your HTML and apply your CSS.</p>\n</section>","id":"66a37f37ef5823a313de8c26","hasEditableBoundaries":false,"instructions":null,"notes":null,"challengeType":14,"helpCategory":"HTML-CSS","videoUrl":null,"superBlock":"front-end-development","translationPending":false,"forumTopicId":null,"fields":{"blockName":"lab-moon-orbit","slug":"/learn/front-end-development/lab-moon-orbit/build-a-moon-orbit","tests":[{"text":"<p>The contents of the <code>body</code> element should be centered on the page by setting the height to <code>100%</code> of the viewport height, <code>display</code> to <code>flex</code>, <code>justify-content</code>, and <code>align-items</code> to <code>center</code>.</p>","testString":"\nassert(new __helpers.CSSHelp(document).getStyle('body')?.height === '100vh' && new __helpers.CSSHelp(document).getStyle('body')?.display === 'flex' && new __helpers.CSSHelp(document).getStyle('body')?.justifyContent === 'center'&& new __helpers.CSSHelp(document).getStyle('body')?.alignItems === 'center');"},{"text":"<p>You should have a main <code>div</code> with the class <code>space</code>.</p>","testString":"assert(document.querySelector('div')?.getAttribute('class') === 'space');"},{"text":"<p>The <code>space</code> <code>div</code> should have a width and height of <code>200px</code>.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.space')?.width === '200px' && new __helpers.CSSHelp(document).getStyle('.space')?.height === '200px');"},{"text":"<p>You should have a <code>div</code> with the class <code>earth</code> inside the <code>.space</code> <code>div</code>.</p>","testString":"assert.exists(document.querySelector('div.space div.earth'));"},{"text":"<p>The <code>earth</code> div should be the first child of the <code>space</code> <code>div</code>.</p>","testString":"assert(document.querySelector('.space > div')?.getAttribute('class') === 'earth');"},{"text":"<p>The <code>earth</code> <code>div</code> should have a width and height of <code>100px</code>.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.earth')?.width === '100px' && new __helpers.CSSHelp(document).getStyle('.earth')?.height === '100px');"},{"text":"<p>The <code>earth</code> <code>div</code> should use <code>absolute</code> positioning.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.earth')?.position === 'absolute');"},{"text":"<p>The <code>earth</code> <code>div</code> should have a <code>top</code> and <code>left</code> position of <code>50%</code>.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.earth')?.top === '50%' && new __helpers.CSSHelp(document).getStyle('.earth')?.left === '50%');"},{"text":"<p>The <code>earth</code> <code>div</code> should be moved back and up by <code>50%</code> by setting the <code>transform</code> property to <code>translate(-50%, -50%)</code>.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.earth')?.transform === 'translate(-50%, -50%)');"},{"text":"<p>You should have a <code>div</code> with the class <code>orbit</code> inside the <code>.space</code> <code>div</code>.</p>","testString":"assert.exists(document.querySelector('div.space div.orbit'));"},{"text":"<p>The <code>orbit</code> class <code>div</code> should come after the <code>earth</code> class <code>div</code>.</p>","testString":"assert(document.querySelector('.earth')?.nextElementSibling?.classList?.contains('orbit'));"},{"text":"<p>The <code>orbit</code> <code>div</code> should have a width and height of <code>200px</code>.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.orbit')?.width === '200px' && new __helpers.CSSHelp(document).getStyle('.orbit')?.height === '200px');"},{"text":"<p>The <code>orbit</code> <code>div</code> should use <code>absolute</code> positioning.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.orbit')?.position === 'absolute');"},{"text":"<p>The <code>orbit</code> <code>div</code> should be positioned at the center of the <code>space</code> <code>div</code> using a <code>transform</code> property that shifts it by <code>-50%</code> on both the vertical and horizontal axes.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.orbit')?.transform === 'translate(-50%, -50%)');"},{"text":"<p>You should have a <code>div</code> with the class <code>moon</code> inside the <code>.orbit</code> <code>div</code>.</p>","testString":"assert.exists(document.querySelector('div.space div.orbit div.moon'));"},{"text":"<p>The <code>moon</code> <code>div</code> should have a width and height of <code>30px</code>.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.moon')?.width === '30px' && new __helpers.CSSHelp(document).getStyle('.moon')?.height === '30px');"},{"text":"<p>The <code>moon</code> <code>div</code> should be positioned using <code>absolute</code> positioning.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.moon')?.position === 'absolute');"},{"text":"<p>The top edge of the <code>.moon</code> element should be aligned with the top edge of its containing block.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.moon')?.top === '0px');"},{"text":"<p>You should move the left edge of the <code>.moon</code> element to the center of the containing block (<code>50%</code> from the left side).</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.moon')?.left === '50%');"},{"text":"<p>The <code>.moon</code> <code>div</code> should be adjusted horizontally by translating it to <code>-50%</code> across the x-axis.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.moon')?.transform === 'translateX(-50%)');"},{"text":"<p>Your <code>.earth</code> <code>div</code> element should have a background color.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.earth')?.backgroundColor);"},{"text":"<p>Your <code>.earth</code> element should have <code>border-radius</code> of <code>50%</code> to make it look like a circle.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.earth')?.borderRadius === '50%');"},{"text":"<p>Your <code>.moon</code> <code>div</code> element should have a background color.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.moon')?.backgroundColor);"},{"text":"<p>Your <code>.moon</code> element should have <code>border-radius</code> of <code>50%</code> to make it look like a circle.</p>","testString":"assert(new __helpers.CSSHelp(document).getStyle('.moon')?.borderRadius === '50%');"},{"text":"<p>You should have a <code>@keyframes</code> rule.</p>","testString":"assert(new __helpers.CSSHelp(document).getCSSRules('keyframes')?.length === 1);"},{"text":"<p>Your new <code>@keyframes</code> rule should be named <code>orbit</code>.</p>","testString":"assert(new __helpers.CSSHelp(document).getCSSRules('keyframes')?.[0]?.name === 'orbit');"},{"text":"<p>Your <code>@keyframes orbit</code> rule should have a <code>0%</code> selector.</p>","testString":"const rules = new __helpers.CSSHelp(document).getCSSRules('keyframes')?.[0]?.cssRules\nassert(rules?.[0]?.keyText === '0%' || rules?.[0]?.keyText === '0%');"},{"text":"<p>Your <code>@keyframes orbit</code> rule should have a <code>100%</code> selector.</p>","testString":"const rules = new __helpers.CSSHelp(document).getCSSRules('keyframes')?.[0]?.cssRules\nassert(rules?.[0]?.keyText === '100%' || rules?.[1]?.keyText === '100%');"},{"text":"<p>Your <code>0%</code> selector should have a <code>transform</code> property set to <code>rotate(0deg) translate(-50%, -50%)</code>.</p>","testString":"assert(new __helpers.CSSHelp(document).getCSSRules('keyframes')?.[0]?.cssRules?.[0]?.style?.transform === 'rotate(0deg) translate(-50%, -50%)');"},{"text":"<p>Your <code>100%</code> selector should come after your <code>0%</code> selector.</p>","testString":"assert(new __helpers.CSSHelp(document).getCSSRules('keyframes')?.[0]?.cssRules?.[1]?.keyText === '100%')"},{"text":"<p>Your <code>100%</code> selector should have a <code>transform</code> property set to <code>rotate(360deg) translate(-50%, -50%)</code>.</p>","testString":"assert(new __helpers.CSSHelp(document).getCSSRules('keyframes')?.[0]?.cssRules?.[1]?.style?.transform === 'rotate(360deg) translate(-50%, -50%)')"},{"text":"<p>Your <code>.orbit</code> selector should have an <code>animation</code> property set to <code>orbit 5s linear infinite</code>.</p>","testString":"\nconst orbitStyles = new __helpers.CSSHelp(document).getStyle('.orbit');\nassert(\n  orbitStyles?.animationName === \"orbit\" &&\n    orbitStyles?.animationDuration === \"5s\" &&\n    orbitStyles?.animationTimingFunction === \"linear\" &&\n    orbitStyles?.animationIterationCount === \"infinite\"\n);\n"}]},"required":[],"usesMultifileEditor":true,"challengeFiles":[{"fileKey":"indexhtml","ext":"html","name":"index","contents":"<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n    <meta charset=\"utf-8\">\n    <title>Moon Orbit</title>\n</head>\n\n<body>\n\n</body>\n\n</html>","head":"","tail":"","editableRegionBoundaries":[],"history":["index.html"]},{"fileKey":"stylescss","ext":"css","name":"styles","contents":"","head":"","tail":"","editableRegionBoundaries":[],"history":["styles.css"]}]}}},"pageContext":{"challengeMeta":{"blockHashSlug":"/learn/front-end-development/#lab-moon-orbit","dashedName":"build-a-moon-orbit","certification":"front-end-development","disableLoopProtectTests":false,"disableLoopProtectPreview":false,"superBlock":"front-end-development","block":"lab-moon-orbit","isFirstStep":true,"template":null,"required":[],"nextBlock":"lab-personal-portfolio","nextChallengePath":"/learn/front-end-development/lab-personal-portfolio/build-a-personal-portfolio","prevChallengePath":"/learn/front-end-development/quiz-css-grid/quiz-css-grid","id":"66a37f37ef5823a313de8c26"},"projectPreview":{"challengeData":{"challengeType":14,"challengeFiles":[{"name":"index","ext":"html","contents":"<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Moon Orbiting Earth</title>\n    <link rel=\"stylesheet\" href=\"styles.css\">\n</head>\n\n<body>\n    <div class=\"space\">\n        <div class=\"earth\"></div>\n        <div class=\"orbit\">\n            <div class=\"moon\"></div>\n        </div>\n    </div>\n</body>\n\n</html>","head":"","tail":"","history":["index.html"],"fileKey":"indexhtml"},{"name":"styles","ext":"css","contents":"body {\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    height: 100vh;\n    margin: 0;\n    background-color: #000;\n}\n\n.space {\n    position: relative;\n    width: 200px;\n    height: 200px;\n}\n\n.earth {\n    width: 100px;\n    height: 100px;\n    background-color: blue;\n    border-radius: 50%;\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    box-shadow: 0 0 20px rgba(0, 0, 255, 0.5);\n}\n\n.orbit {\n    width: 200px;\n    height: 200px;\n    position: absolute;\n    transform: translate(-50%, -50%);\n    animation: orbit 5s linear infinite;\n}\n\n.moon {\n    width: 30px;\n    height: 30px;\n    background-color: gray;\n    border-radius: 50%;\n    position: absolute;\n    top: 0;\n    left: 50%;\n    transform: translateX(-50%);\n    box-shadow: 0 0 10px rgb(255, 255, 255);\n}\n\n\n@keyframes orbit {\n    0% {\n        transform: rotate(0deg) translate(-50%, -50%);\n    }\n\n    100% {\n        transform: rotate(360deg) translate(-50%, -50%);\n    }\n}","head":"","tail":"","history":["styles.css"],"fileKey":"stylescss"}]}},"id":"/learn/front-end-development/lab-moon-orbit/build-a-moon-orbit"}},
    "staticQueryHashes": ["4268002518","813102432"]}