Skip to content

Commit 2d574da

Browse files
authored
feat(curriculum): add interactive examples to width and height lesson (freeCodeCamp#62771)
1 parent af70a07 commit 2d574da

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

curriculum/challenges/english/blocks/lecture-what-is-css/672acc03c257524d6a5151e8.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ challengeType: 19
55
dashedName: how-do-width-and-height-work
66
---
77

8-
# --description--
8+
# --interactive--
99

1010
In CSS, the `width` and `height` properties are used to control the dimensions of elements on a webpage.
1111

@@ -17,6 +17,8 @@ The `height` property specifies the height of an element. Similarly, the height
1717

1818
Here's an example using the `width` and `height` properties:
1919

20+
:::interactive_editor
21+
2022
```html
2123
<head>
2224
<style>
@@ -32,6 +34,8 @@ Here's an example using the `width` and `height` properties:
3234
</body>
3335
```
3436

37+
:::
38+
3539
In this example, we have a `div` element with class named `box`. This element will be occupying `100px` in height and width, whereas the background color will be `skyblue`.
3640

3741
Pixels are a fixed-size unit of measurement in CSS, providing precise control over dimensions.
@@ -42,6 +46,8 @@ The `min-height` specifies the minimum height an element can be. It ensures that
4246

4347
Here is an example:
4448

49+
:::interactive_editor
50+
4551
```html
4652
<head>
4753
<style>
@@ -59,6 +65,8 @@ Here is an example:
5965
</body>
6066
```
6167

68+
:::
69+
6270
The above example demonstrates how `min-width` and `min-height` work.
6371

6472
Even though the box has its `width` and `height` set to 50px, it will actually be `100px` by `100px`. This is because the `min-width` and `min-height` are set to `100px`, which are larger than the specified `width` and `height`.
@@ -71,6 +79,8 @@ The `max-height` specifies the maximum height an element can grow to, regardless
7179

7280
Here is an example:
7381

82+
:::interactive_editor
83+
7484
```html
7585
<head>
7686
<style>
@@ -88,6 +98,8 @@ Here is an example:
8898
</body>
8999
```
90100

101+
:::
102+
91103
The above example demonstrates how `max-width` and `max-height` override `width` and `height`. Even though the box is set to `200px` by `200px`, it will actually be `150px` by `150px`. This is because the `max-width` and `max-height` are set to `150px`, which is smaller.
92104

93105
Remember, when `max-width` or `max-height` are smaller than `width` or `height`, they take precedence. This is important for controlling the maximum size of elements in your layouts.

0 commit comments

Comments
 (0)