Using "layout" in theme.json adds margin-left and -right: auto with !important to full width elements #33956
Labels
Comments
cc @nosolosw in case you have thoughts here :) |
@youknowriad would know best about layout things. |
!important is unfortunately necessary here because left/right margins applied to children blocks using the margin UI for instance (non aligned) shouldn't apply because the block should remain centered in the "content area". We tried other solutions to "center" blocks without relying on That said, the negative margins above are added by the editor itself, I think adding important there might be an acceptable stop gap fix for now (for full aligned blocks). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
philbuchanan commentedAug 9, 2021
Is there an existing issue for this?
Have you tried deactivating all plugins except Gutenberg?
Have you tried replicating the bug using a default theme e.g. Twenty Twenty?
Description
When you add
"layout": { "contentSize": "800px" }
to the theme.json file, it adds the following CSS to the editor:If you add a block with
alignfull
it resets the width withmax-width: none;
but the margin-left and right which are set as such:cannot be overridden due to the
!important
.The result is an extra space of 8 pixels on each side of the editor.
Step-by-step reproduction instructions
See above.
Expected Behavior
Generally, I think the use of
!important
should be avoided since it makes it nearly impossible to override styles. Specifically, in this case, I'm not sure why the!important
is necessary at all. I would expect the-8px
margins to be applied toalignfull
elements.Current Behavior
See above.
Screenshots or screen recording (optional)
No response
Code snippet (optional)
No response
WordPress Information
WordPress 5.8
Gutenberg Information
Not using the Gutenberg plugin.
What browsers are you seeing the problem on?
Firefox, Chrome, Safari, Microsoft Edge
Device Information
No response
Operating System Information
No response
The text was updated successfully, but these errors were encountered: