You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: data/blog/going-beyond-pixels-and-rems-in-css/container-query-length-units.mdx
+10-7
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ Ok, we’ve set our `container-type` and added some basic styling, It’s time t
51
51
52
52
## cqw
53
53
54
-
The `cwq` unit stands for **1% of the containing element's width**. It allows you to define element sizes and spacing relative to the width of their container in contrast to the `vw` unit, which defines the spacing relative to the viewport. But just as viewport and font units, it can be used in any property that accepts `<length>` values, such as `font-size`, `width`, `padding`, `margin`, etc. The latter counts for every unit we will tackle in this article.
54
+
The `cqw` unit stands for **1% of the containing element's width**. It allows you to define element sizes and spacing relative to the width of their container in contrast to the `vw` unit, which defines the spacing relative to the viewport. But just as viewport and font units, it can be used in any property that accepts `<length>` values, such as `font-size`, `width`, `padding`, `margin`, etc. The latter counts for every unit we will tackle in this article.
55
55
56
56
Now, a demo says more than a thousand words, so let’s put it to the test. Let’s add a margin to our previous code for the `.item` inside of the container:
57
57
@@ -76,8 +76,9 @@ Now the item will have a margin based on its container. This is what you should
76
76
allowfullscreen="true"
77
77
>
78
78
See the Pen <ahref="https://codepen.io/utilitybend/pen/jOJjbez">Basic container unit example</a>
79
-
by utilitybend (<ahref="https://codepen.io/utilitybend">@utilitybend</a>) on{''}
80
-
<ahref="https://codepen.io">CodePen</a>.
79
+
by utilitybend (<ahref="https://codepen.io/utilitybend">@utilitybend</a>) on <ahref="https://codepen.io">
80
+
CodePen
81
+
</a>.
81
82
</iframe>
82
83
83
84
Now let’s make the effect stick out a bit more by making some other properties rely on the `cqw` unit.
@@ -107,8 +108,9 @@ Now we can see the effect on roids. If you add a few extra containers with diffe
0 commit comments