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
divelement in the component, use<div>...</div>. - To pass
props.childrenas the text content enclose it within{...}and setprops.children. Result:<div>{props.children}</div>. - To add a class name to the
divelement, use theclassNameattribute and set it toalert. Result:className="alert". - To import the file with styles in the
index.jsfile, useimportstatement and provide the correct path to the file. Result:import './index.css'. - To apply styles to the
divelement, use the class name selector.alertand insert the styles from the task.
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 22
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください
セクション 1. 章 22