-
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
Fix image caption margins #9566
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,11 @@ | |
.aligncenter, | ||
&.is-resized { | ||
display: table; | ||
margin: 0; | ||
|
||
// The figure is born with left and right margin. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note the removal of top and bottom margin rules. We let the theme handle those. The |
||
// We remove this by default, and then customize it for left, right, and center. | ||
margin-left: 0; | ||
margin-right: 0; | ||
|
||
> figcaption { | ||
display: table-caption; | ||
|
@@ -38,9 +42,9 @@ | |
margin-left: 1em; | ||
} | ||
|
||
// Centered images. | ||
.aligncenter { | ||
margin: 0 auto; | ||
margin-left: auto; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still need to customize the centering, but rules here were rewritten to refer to the previous rules above. |
||
margin-right: auto; | ||
} | ||
|
||
// Supply caption styles to images, even if the theme hasn't opted in. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary for themes that zero out the margin on the
figure
, which many themes do.Could be worth visiting separately, adding a default margin to the image block, so they don't all stack up next to each other. Or not? Maybe that's squarely theme territory. Could be a theme.scss property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, this makes sure things don't look broken out of the box on many themes (TwentyFifteen, Independent Publisher 2, etc.)
This is definitely worth exploring. Ideally, images inserted via Gutenberg (inside of
figure
/div
wrappers) are styled exactly like images inserted normally (without those wrappers). Not sure the right answer, but it's worth an exploration.