Skip to content

Instantly share code, notes, and snippets.

@arthurbuhl
Forked from palashmon/image-reset.css
Created February 27, 2024 05:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurbuhl/103289205a88f8b2bb9d9fa677af9a44 to your computer and use it in GitHub Desktop.
Save arthurbuhl/103289205a88f8b2bb9d9fa677af9a44 to your computer and use it in GitHub Desktop.
A More Effective CSS Image Reset
/**
* This CSS block is a More Effective CSS Image Reset.
* It resets the default styles of an image element
* and adds some additional styles to improve its rendering.
*
* The `max-width: 100%;` ensures that the image does not exceed its container's width,
* while maintaining its aspect ratio with `height: auto;`.
*
* The `vertical-align: middle;` aligns the image vertically with the text.
*
* The `font-style: italic;` adds a slight italic effect to the image alt text.
*
* The `background-repeat: no-repeat;` ensures that the image does not repeat itself.
*
* The `background-size: cover;` ensures that the image fills its container without repeating.
*
* Finally, the `shape-margin: 1rem;` adds some margin around the image to improve its spacing with other elements.
*/
img {
max-width: 100%;
height: auto;
vertical-align: middle;
font-style: italic;
background-repeat: no-repeat;
background-size: cover;
shape-margin: 1rem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment