Created
April 7, 2021 23:41
-
-
Save gkweb/652c0bcb1b50d44bb18db1f75058dd06 to your computer and use it in GitHub Desktop.
Web vitals easy dimensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* author: @gkweb | |
* Add this as an inline style tag to the <head> | |
* | |
* Adjust for whatever media query structure you have | |
* Helps with CLS - The style is there immediately and this means you can set dimensions for every screensize | |
*/ | |
@media screen and (min-width: 480px) { | |
[data-sm-width] { | |
width: attr(data-sm-width); | |
} | |
[data-sm-height] { | |
height: attr(data-sm-height); | |
} | |
} | |
/* Example <img width="100" height="100" data-sm-width="200" data-sm-width="200" /> */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment