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

Fix oversized images #3258

Merged
merged 1 commit into from
Jul 9, 2024
Merged

Fix oversized images #3258

merged 1 commit into from
Jul 9, 2024

Conversation

andysellick
Copy link
Contributor

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

What / why

  • fix oversized images on the 'how government works' page https://www.gov.uk/government/how-government-works
  • remove hard coded image dimensions and add a class that sets max-width: 100%
  • was causing the images to overlap the width of the screen at small screen sizes, causing a horizontal scroll bar and a broken layout
  • only adding the class or only removing the width/height don't fix the problem, because width/height as inline attributes override CSS
  • was hoping to be able to leave the width/height to reduce cumulative layout shift when loading, but this is a small loss compared to fixing the general appearance
  • surprised we don't have a general class to have all img tags with max-width: 100% but since there isn't one I don't want to try introducing one here as proving it's fine on every page is a much bigger task (although logically it should be... right?)

Page with the problem: https://www.gov.uk/government/how-government-works

(I've checked for other image tags within government-frontend and this seems to be the only instance of this problem)

Example of the problem:

Screenshot 2024-07-08 at 16 03 56

Visual changes

Before After
Screenshot 2024-07-08 at 16 01 01 Screenshot 2024-07-08 at 16 03 00

Trello card: https://trello.com/c/USYdcgFe/235-image-off-the-right-hand-side-of-the-screen

- fix oversized images on the 'how government works' page https://www.gov.uk/government/how-government-works
- remove hard coded image dimensions and add a class that sets `max-width: 100%`
- was causing the images to overlap the width of the screen at small screen sizes, causing a horizontal scroll bar and a broken layout
- only adding the class or only removing the width/height don't fix the problem, because width/height as inline attributes override CSS
- was hoping to be able to leave the width/height to reduce cumulative layout shift when loading, but this is a small loss compared to fixing the general appearance
- surprised we don't have a general class to have all `img` tags with `max-width: 100%` but since there isn't one I don't want to try introducing one here as proving it's fine on every page is a much bigger task (although logically it should be... right?)
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3258 July 8, 2024 15:05 Inactive
@andysellick andysellick merged commit 0a26849 into main Jul 9, 2024
12 checks passed
@andysellick andysellick deleted the fix-big-images branch July 9, 2024 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants