|
2622 | 2622 | "id": "587d78a6367417b2b2512ade",
|
2623 | 2623 | "title": "Create a More Complex Shape Using CSS and HTML",
|
2624 | 2624 | "description": [
|
2625 |
| - "One of the most popular shapes in the world is the heart shape, and this challenge creates it with raw CSS. But first, you need to understand the <code>:before</code> and <code>:after</code> selectors. These selectors are used to add something before or after a selected element. In the following example, a <code>:before</code> selector is used to add a rectangle to an element with the class <code>heart</code>:", |
2626 |
| - "<blockquote>.heart:before {<br> content: \"\";<br> background-color: yellow;<br> border-radius: 25%;<br> position: absolute;<br> height: 50px;<br> width: 70px;<br> top: -50px;<br> left: 5px;<br>}</blockquote>", |
2627 |
| - "For the <code>:before</code> and <code>:after</code> selectors to function properly, they must have a defined <code>content</code> property. It usually has content such as a photo or text. When the <code>:before</code> and <code>:after</code> selectors add shapes, the <code>content</code> property is still required, but it's set to an empty string.", |
2628 |
| - "In the above example, the element with the class of <code>heart</code> has a <code>:before</code> selector that produces a yellow rectangle with <code>height</code> and <code>width</code> of 50px and 70px, respectively. This rectangle has round corners due to its 25% border radius and is positioned absolutely at 5px from the <code>left</code> and 50px above the <code>top</code> of the element.", |
| 2625 | + "One of the most popular shapes in the world is the heart shape, and in this challenge you'll create one using pure CSS. But first, you need to understand the <code>::before</code> and <code>::after</code> pseudo-elements. These pseudo-elements are used to add something before or after a selected element. In the following example, a <code>::before</code> pseudo-element is used to add a rectangle to an element with the class <code>heart</code>:", |
| 2626 | + "<blockquote>.heart::before {<br> content: \"\";<br> background-color: yellow;<br> border-radius: 25%;<br> position: absolute;<br> height: 50px;<br> width: 70px;<br> top: -50px;<br> left: 5px;<br>}</blockquote>", |
| 2627 | + "For the <code>::before</code> and <code>::after</code> pseudo-elements to function properly, they must have a defined <code>content</code> property. This property is usually used to add things like a photo or text to the selected element. When the <code>::before</code> and <code>::after</code> pseudo-elements are used to make shapes, the <code>content</code> property is still required, but it's set to an empty string.", |
| 2628 | + "In the above example, the element with the class of <code>heart</code> has a <code>::before</code> pseudo-element that produces a yellow rectangle with <code>height</code> and <code>width</code> of 50px and 70px, respectively. This rectangle has round corners due to its 25% border radius and is positioned absolutely at 5px from the <code>left</code> and 50px above the <code>top</code> of the element.", |
2629 | 2629 | "<hr>",
|
2630 |
| - "Transform the element on the screen to a heart. In the <code>heart:after</code> selector, change the <code>background-color</code> to pink and the <code>border-radius</code> to 50%.", |
| 2630 | + "Transform the element on the screen to a heart. In the <code>heart::after</code> selector, change the <code>background-color</code> to pink and the <code>border-radius</code> to 50%.", |
2631 | 2631 | "Next, target the element with the class <code>heart</code> (just <code>heart</code>) and fill in the <code>transform</code> property. Use the <code>rotate()</code> function with -45 degrees. (<code>rotate()</code> works the same way that <code>skewX()</code> and <code>skewY()</code> do).",
|
2632 |
| - "Finally, in the <code>heart:before</code> selector, set its <code>content</code> property to an empty string." |
| 2632 | + "Finally, in the <code>heart::before</code> selector, set its <code>content</code> property to an empty string." |
2633 | 2633 | ],
|
2634 | 2634 | "tests": [
|
2635 | 2635 | {
|
2636 | 2636 | "text":
|
2637 |
| - "The <code>background-color</code> property of the <code>heart:after</code> selector should be pink.", |
| 2637 | + "The <code>background-color</code> property of the <code>heart::after</code> selector should be pink.", |
2638 | 2638 | "testString":
|
2639 |
| - "assert(code.match(/\\.heart:after\\s*?{\\s*?background-color\\s*?:\\s*?pink\\s*?;/gi), 'The <code>background-color</code> property of the <code>heart:after</code> selector should be pink.');" |
| 2639 | + "assert(code.match(/\\.heart::after\\s*?{\\s*?background-color\\s*?:\\s*?pink\\s*?;/gi), 'The <code>background-color</code> property of the <code>heart::after</code> selector should be pink.');" |
2640 | 2640 | },
|
2641 | 2641 | {
|
2642 | 2642 | "text":
|
2643 |
| - "The <code>border-radius</code> of the <code>heart:after</code> selector should be 50%.", |
| 2643 | + "The <code>border-radius</code> of the <code>heart::after</code> selector should be 50%.", |
2644 | 2644 | "testString":
|
2645 |
| - "assert(code.match(/border-radius\\s*?:\\s*?50%/gi).length == 2, 'The <code>border-radius</code> of the <code>heart:after</code> selector should be 50%.');" |
| 2645 | + "assert(code.match(/border-radius\\s*?:\\s*?50%/gi).length == 2, 'The <code>border-radius</code> of the <code>heart::after</code> selector should be 50%.');" |
2646 | 2646 | },
|
2647 | 2647 | {
|
2648 | 2648 | "text":
|
|
2652 | 2652 | },
|
2653 | 2653 | {
|
2654 | 2654 | "text":
|
2655 |
| - "The <code>content</code> of the <code>heart:before</code> selector should be an empty string.", |
| 2655 | + "The <code>content</code> of the <code>heart::before</code> selector should be an empty string.", |
2656 | 2656 | "testString":
|
2657 |
| - "assert(code.match(/\\.heart:before\\s*?{\\s*?content\\s*?:\\s*?(\"|')\\1\\s*?;/gi), 'The <code>content</code> of the <code>heart:before</code> selector should be an empty string.');" |
| 2657 | + "assert(code.match(/\\.heart::before\\s*?{\\s*?content\\s*?:\\s*?(\"|')\\1\\s*?;/gi), 'The <code>content</code> of the <code>heart::before</code> selector should be an empty string.');" |
2658 | 2658 | }
|
2659 | 2659 | ],
|
2660 | 2660 | "solutions": [],
|
|
2681 | 2681 | " width: 50px;",
|
2682 | 2682 | " transform: ;",
|
2683 | 2683 | "}",
|
2684 |
| - ".heart:after {", |
| 2684 | + ".heart::after {", |
2685 | 2685 | " background-color: blue;",
|
2686 | 2686 | " content: \"\";",
|
2687 | 2687 | " border-radius: 25%;",
|
|
2691 | 2691 | " top: 0px;",
|
2692 | 2692 | " left: 25px;",
|
2693 | 2693 | "}",
|
2694 |
| - ".heart:before {", |
| 2694 | + ".heart::before {", |
2695 | 2695 | " content: ;",
|
2696 | 2696 | " background-color: pink;",
|
2697 | 2697 | " border-radius: 50%;",
|
|
0 commit comments