Skip to content
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

Cannot center align image within cover #44810

Closed
Andrew-Starr opened this issue Oct 10, 2022 · 3 comments
Closed

Cannot center align image within cover #44810

Andrew-Starr opened this issue Oct 10, 2022 · 3 comments
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Type] Bug An existing feature does not function as intended

Comments

@Andrew-Starr
Copy link

Description

With an image inside a cover, setting the image to align center does not center the image.

Step-by-step reproduction instructions

Add a cover block.
Add a smaller image inside the cover.
Set the image alignment property to center.
The image does not align to the center, and is incorrectly left aligned.

Screenshots, screen recording, code snippet

cover-image-center

Environment info

Latest WP and Gutenberg.
Issue is also present without Gutenberg active.

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

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Block] Cover Affects the Cover Block - used to display content laid over a background image labels Oct 10, 2022
@Mamaduka
Copy link
Member

Thanks for contributing, @Andrew-Starr!

I wonder if this is related to the Cover missing layout support.

If I wrap it into the Group block, I can get image alignments working correctly.

@Andrew-Starr
Copy link
Author

I should also mention that the issue seems to only be present with block themes.

With a classic theme, WP core or Gutenberg provides the following block styling that will center align an image wherever it is placed.

.wp-block-image .aligncenter {
  margin-left: auto;
  margin-right: auto;
}

This styling is not present when a block theme is active.

Instead centering seems to be styled in Gutenberg:

body .is-layout-flow > .aligncenter {
  margin-left: auto !important;
  margin-right: auto !important;
}

The issue with this is that the parent container <div class="wp-block-cover__inner-container"> does not contain the is-layout-flow class.

And in core:

.wp-container-8 > .aligncenter {
  margin-left: auto !important;
  margin-right: auto !important;
}

Similarly here the cover inner container is missing from the generated inline container styling.

@jordesign
Copy link
Contributor

I can no longer recreate this - images within cover blocks can be center aligned in WP6.3.

Closing this issue as no longer reproducible

@jordesign jordesign closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants