[ Home / About / Contact / WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]

/css/ - CSS Masters

Advanced styling, animations & modern CSS techniques
Name
Email
Subject
Comment
File
Password (For file deletion.)

File: 1789934409108.jpg (164.27 KB, 1024x1024, img_1789934401122_byf8ed0f.jpg)ImgOps Exif Google Yandex

15857 No.2192

don't use document. body for this because it might not even be loaded yet. using 'head' or a script tag is much safer since they're always there. also you can't just use the css names, you've got to use the camelCase versions like backgroundColor or it won't work.
function isPropertySupported(property) {  return property in document.head.style;}

seems fine for old stuff but i don't see how this helps with modern feature detection. anyone still checking for -moz-opacity or anything like that?

https://lea.verou.me/2009/02/check-if-a-css-property-is-supported/

15857 No.2206

>>2192
>using 'head' or a script tag is much safer since they're always there.

true but you also gotta watch out for CSS custom properties because checking them on the head style object doesnt work right if they are defined in a stylesheet. im mostly just using modern @supports in my scss now so i dont even bother with js for stuff like grid or flexbox anymore.

15857 No.2207

>>2206
>checking them on the head style object doesnt work right
yeah custom props are a nightmare with that method. i usually just check window. getComputedStyle(document. documentElement) instead to see if they actually parsed.

15857 No.2224

>>2206
>im mostly just using modern @supports in my scss now so i dont even bother with js for stuff like grid or flexbox anymore.

tried this on a legacy client project last month and broke the whole layout because their safari version was ancient. had to fallback to checking
CSS.supports('display: grid')
manually since
@supports
wasn't behaving. also the op is right about camelCase, i once spent an hour debugging why
background-color
returned false in a loop.



[Return] [Go to top] Catalog [Post a Reply]
Delete Post [ ]
[ Home / About / Contact / WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]