Maximum width for cover block overlay?
-
I’m developing a custom block theme, and I’m trying to leverage the ability to overlay blocks on top of a cover block, when the cover is set to full-width.
By default, the overlaid content also goes to full width, which I really don’t think looks great. Maybe there are uses for it, but in my mind the natural “default” would be that the overlaid content matches the regular content width unless you specify otherwise, that way the cover image serves its role as a background element, and the foreground content flows smoothly from the cover block to adjacent blocks.
I’ve come up with a solution for now, but I don’t love it, and I’m wondering if someone has a better way.
My solution is to add a custom setting in
theme.json
:"custom": { "core": { "cover": { "maxInnerWidth": "960px" } } }
And then in my CSS I’m doing this:
.wp-block-cover.alignfull { padding-right: calc(calc(100vw - var(--wp--custom--core--cover--max-inner-width)) / 2); padding-left: calc(calc(100vw - var(--wp--custom--core--cover--max-inner-width)) / 2); }
It works! But it doesn’t feel right to me. Is there a better way to accomplish this? Is there a rationale for why cover blocks don’t work this way by default (or at least provide this as a built-in option)?
- The topic ‘Maximum width for cover block overlay?’ is closed to new replies.