-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modifying block gap on wrapper elements quickly breaks the cascade #40280
Comments
I've set up a pen at https://codepen.io/permanenttourist/pen/QWaVwbO?editors=1100 to explain what I mean. |
Hi @markhowellsmead, setting |
That's not possible: the padding and margin controls have to be disabled for most of our projects. The sizing and spacing has to be controlled by CSS. Addendum: almost all of our clients explicitly don't want editors to have access to layout or typographic controls. |
In that case can you target the block using the |
Yes, but that tends to make the use of Without removing block gap, it would be difficult to amend margins on elements where the margins are set using inline CSS by core. As mentioned in #40159, the inline styles always have priority over linked theme stylesheets, which makes overriding them difficult or impossible. Especially where semantic class names are now missing. (#38719) |
Would it? If you did something like:
Then all navigation blocks would get a new gap, but all the other places where |
I see what you mean, but that would lead to confusion in complex projects, where the gap is sometimes controlled using |
I was looking at ways to control this today and came across this ticket. Often, I'll have three main inner elements within the page: <div class="wp-site-blocks">
<header></header>
<main></main>
<footer></footer>
</div> Generally, I don't want spacing between those blocks (it makes it tough to customize padding and backgrounds). However, I need Overwriting the Solution 1: If you're not worried about user customization of the layout (typical of client work), you can set this via CSS: .wp-site-blocks > * + * {
margin-block-start: 0;
} That will zero out the "gap" between blocks nested directly underneath This is basically what @scruffian was saying to do. You just need to hit Solution 2: If you'd like to allow users full customization of this from the UI, the next best solution is to wrap everything in an extra Group block within your templates (yeah, I know, divitis, but what can you do?): <!-- wp:group {"style":{"spacing":{"blockGap":"0"}},"layout":{"type":"default"}} -->
<div class="wp-block-group">
Your blocks go here.
</div>
<!-- /wp:group --> Edit: Basically, the problem from core/Gutenberg here is that the "setting" for the block gap is under |
Bumping this -- it's still a problem for theme and plugin developers. |
See also #54010. |
Description
If I modify the block gap on a specific wrapper element, then this CSS custom property value inherits down to all descendants unless explicitly overridden. This isn't maintainable for an endlessly customisable stack of HTML elements.
Step-by-step reproduction instructions
Assuming the following structure:
If I set
--wp--style--block-gap
to 0 on.wp-site-blocks
, all of the nested elements lose their default gaps. I then have to override--wp--style--block-gap
manually on every potential descendant element.Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: