Challenge: Style a React Application
ã¡ãã¥ãŒã衚瀺ããã«ã¯ã¹ã¯ã€ãããŠãã ãã
Task
We will now proceed to create the Alert component, which will render all the elements passed as children and apply some specific styles to it. The task is:
- Create the component
Alertthat has thedivelement inside. - The
divelement should have thealertclass name. - The
divelement should have thechildrenprop as the content. - The
divelement should have the following CSS.
padding: 20px;
border-radius: 10px;
background-color: lightgreen;
color: darkmagenta;
- To create aÂ
div element in the component, useÂ<div>...</div>. - To passÂ
props.children as the text content enclose it withinÂ{...} and setÂprops.children. Result:Â<div>{props.children}</div>. - To add a class name to theÂ
div element, use theÂclassName attribute and set it toÂalert. Result:ÂclassName="alert". - To import the file with styles in theÂ
index.js file, useÂimport statement and provide the correct path to the file. Result:Âimport './index.css'. - To apply styles to theÂ
div element, use the class name selectorÂ.alert and insert the styles from the task.
ãã¹ãŠæç¢ºã§ãããïŒ
ãã£ãŒãããã¯ããããšãããããŸãïŒ
ã»ã¯ã·ã§ã³Â 1. ç« Â 22
AIã«è³ªåãã
AIã«è³ªåãã
äœã§ã質åããããææ¡ããã質åã®1ã€ã詊ããŠãã£ãããå§ããŠãã ãã