Adapting layout to context
A brief explanation of containers
How to set up a container query
.entity-main-block {
container-type: inline-size;
container-name: ability-container;
}
/* "Inline-size" basically means you want to know the width of the container.
You don’t need to worry about other possible values for this, but MDN describes them in detail. */@container ability-container (max-width: 399px) {
/* Since ability-container is the container-name we gave to .entity-main-block,
everything in here only applies when .entity-main-block is narrower than 400 pixels...
...and only if .entity-main-block is the target’s ancestor! */
.ability h1 {
font-size: 2em;
}
.ability img {
margin-left: 0.5em;
}
}A practical example
Conclusion

Last updated