diff --git a/curriculum/challenges/english/blocks/review-css-relative-and-absolute-units/671a8f8350c20a7439015c98.md b/curriculum/challenges/english/blocks/review-css-relative-and-absolute-units/671a8f8350c20a7439015c98.md index e573eb2d286..27d7659e971 100644 --- a/curriculum/challenges/english/blocks/review-css-relative-and-absolute-units/671a8f8350c20a7439015c98.md +++ b/curriculum/challenges/english/blocks/review-css-relative-and-absolute-units/671a8f8350c20a7439015c98.md @@ -5,7 +5,7 @@ challengeType: 31 dashedName: review-css-relative-and-absolute-units --- -# --description-- +# --interactive-- ## Absolute Units @@ -17,6 +17,74 @@ dashedName: review-css-relative-and-absolute-units - **`pc` (Picas)**: This absolute unit is equal to 1/6th of an inch. - **`pt` (Points)**: This absolute unit is equal to 1/72th of an inch. +:::interactive_editor + +```html + +
+
px
+
in
+
cm
+
mm
+
q
+
pc
+
pt
+
+``` + +```css +.units { + display: flex; + gap: 12px; + flex-wrap: wrap; + align-items: flex-end; +} + +.unit { + background: steelblue; + color: white; + text-align: center; + padding: 4px; +} + +.px { + width: 40px; + height: 40px; +} + +.inch { + width: 0.5in; + height: 0.5in; +} + +.cm { + width: 1cm; + height: 1cm; +} + +.mm { + width: 10mm; + height: 10mm; +} + +.q { + width: 40q; + height: 40q; +} + +.pc { + width: 6pc; + height: 6pc; +} + +.pt { + width: 36pt; + height: 36pt; +} +``` + +::: + ## Relative Units - **Percentages**: These relative units allow you to define sizes, dimensions, and other properties as a proportion of their parent element. For example, if you set `width: 50%;` on an element, it will occupy half the width of its parent container. @@ -25,10 +93,88 @@ dashedName: review-css-relative-and-absolute-units - **`vh` Unit**: `vh` stands for `"viewport height"` and `1vh` is equal to 1% of the viewport's height. - **`vw` Unit**: `vw` stands for `"viewport width"` and `1vw` is equal to 1% of the viewport's width. +:::interactive_editor + +```html + +
+
50%
+
2em
+
2rem
+
10vh
+
10vw
+
+``` + +```css +html { + font-size: 16px; +} + +.parent { + width: 200px; + font-size: 20px; + border: 2px dashed #555; + padding: 10px; + display: flex; + flex-direction: column; + gap: 12px; +} + +.box { + background: seagreen; + color: white; + text-align: center; + padding: 6px; +} + +.percent { + width: 50%; +} + +.em { + font-size: 2em; +} + +.rem { + font-size: 2rem; +} + +.vh { + height: 10vh; +} + +.vw { + width: 10vw; +} +``` + +::: + ## `calc` Function - **`calc()` Function**: With the `calc()` function, you can perform calculations directly within your stylesheets to determine property values dynamically. This means that you can create flexible and responsive user interfaces by calculating dimensions based on the viewport size or other elements. +:::interactive_editor + +```html + +
calc()
+``` + +```css +.calc-box { + width: calc(100% - 40px); + padding: 10px; + background: steelblue; + color: white; + text-align: center; + border: 2px solid black; +} +``` + +::: + # --assignment-- Review the CSS Relative and Absolute Units topics and concepts.