Skip to content

Commit 728dbf3

Browse files
committed
Update css-practice.md
1 parent 2945179 commit 728dbf3

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

css-practice.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,32 @@ Pick ONE OR MORE options
12541254
4. .parent { position: relative; } .child { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
12551255
```
12561256

1257+
<details><summary><b>Answer</b></summary>
1258+
1259+
```css
1260+
.parent {
1261+
display: flex;
1262+
justify-content: center;
1263+
align-items: center;
1264+
}
1265+
```
1266+
1267+
```css
1268+
.parent {
1269+
position: relative;
1270+
}
1271+
.child {
1272+
position: absolute;
1273+
top: 50%;
1274+
left: 50%;
1275+
transform: translate(-50%, -50%);
1276+
}
1277+
```
1278+
1279+
**&#9885; [Try this example on CodeSandbox](https://codesandbox.io/s/css-centering-xdj4lg?file=/src/styles.css)**
1280+
1281+
</details>
1282+
12571283
<div align="right">
12581284
<b><a href="#">↥ back to top</a></b>
12591285
</div>

0 commit comments

Comments
 (0)