-
Notifications
You must be signed in to change notification settings - Fork 150
Fix: Enforce consistent, responsive <figure> styling to match markdown image behavior
#523
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
Conversation
Signed-off-by: Zihan Kuang <zihan_kuang@outlook.com>
✅ Deploy Preview for bejewelled-pegasus-b0ce81 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
Here is a comparison of before and after. before: ScreenRecording_05-02-2025.19-09-06_1.mp4After: ScreenRecording_05-02-2025.19-09-37_1.mp4I’m not positive that the after it is better in Mobile view… What do you think? The 100% with the mobile view might be a little more friendly. |
|
I agree with Lee, the images are too small to be readable, 100% width would be nice. |
| figure, | ||
| figure[style*="width"] { | ||
| width: 100% !important; | ||
| max-width: 70% !important; |
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.
LGTM, but do we really need both as !important?
| <img src="./images/example.png" alt="Example description" style="max-width: 40vw; max-height: 60vh; display: block; margin: 1rem auto;" /> | ||
| ``` | ||
|
|
||
| If you want your image to include a caption for explanation or accessibility, you can use the `<figure>` element: |
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.
these instructions are good 👍🏼
| margin-bottom: 0px !important; | ||
| width: 100% !important; | ||
| height: auto !important; | ||
| object-fit: contain !important; |
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.
is !important on everything needed here?
|
Thanks for the feedback!
Let me know if further adjustments are needed😎 |
|
A quality PR review from, @M-DEV-1. I like it! 🙂 Sound remarks from @zihanKuang, with well-researched justification and responses, too. |
|
Thank you @leecalcote, @zihanKuang thanks for justifying the usage 👌 |
Fix: Enforce consistent, responsive `<figure>` styling to match markdown image behavior
Notes for Reviewers
This PR fixes #522
Problem
The current
<figure>styling does not adapt well when inline style="width:..." is present. In such cases, the figure can exceed the intended content width and introduce excessive horizontal gaps, especially on smaller screens.Resolution
This PR updates the styling of the
<figure>element inassets/scss/_styles_project.scssto:Align with the behavior of markdown images rendered via
layouts/_default/_markup/render-image.htmlEnsure consistent responsiveness by applying:
width: 100%andmax-width: 70%tofigureandfigure[style*="width"]width: 100%to nested<img>and<figcaption>object-fit: contain,display: block, and centered alignmentOverride any inline width declarations (e.g.,
style="width:600px") using!importantAlthough
<figure>is infrequently used (standard markdown image syntax is more common), it remains useful for including captions or grouped content. To support this usage, this PR also updates contributing-to-docs with usage guidance and examples.