Challenge: Implement Absolute Positioning
メニューを表示するにはスワイプしてください
Task
Center the child element (div with the class name child) within the parent element (div with the class name parent) using absolute positioning.
Steps:
- Apply
absolutepositioning to the child element. - Calculate the values for the
topandleftproperties to center the child element within the parent element. The parent element has a width and height of220px, while the child element has a width and height of80px. - Ensure that one element has
absolutepositioning, and the other hasrelativepositioning to establish the correct positioning context. Otherwise, the absolute positioning will be relative to thebodyelement.
index.html
index.css
- To calculate the value for the
topproperty, use the formula:(parentHeight - childHeight) / 2. - To calculate the value for the
leftproperty, use the formula:(parentWidth - childWidth) / 2.
index.html
index.css
すべて明確でしたか?
フィードバックありがとうございます!
セクション 2. 章 5
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください
セクション 2. 章 5