{"id":125,"date":"2019-07-30T16:42:30","date_gmt":"2019-07-30T16:42:30","guid":{"rendered":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/?p=125"},"modified":"2019-08-03T18:53:30","modified_gmt":"2019-08-03T18:53:30","slug":"supports-makes-me-happy","status":"publish","type":"post","link":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/2019\/supports-makes-me-happy\/","title":{"rendered":"@supports makes me happy"},"content":{"rendered":"<p>Alright, obviously I won&#8217;t be changing all the photos on my website whenever I change my color scheme, so giving the photos a little color in CSS would be so much nicer. And in the night I thought: just use <a href=\"https:\/\/www.blindemanwebsites.com\/today-i-learned\/2019\/images-and-before-after\/\">::before and ::after<\/a> with blend modes, then you won&#8217;t need to add any HTML (so no child theme needed) and you can make the photos look however you want with CSS.<\/p>\n<p><!--more-->Since I still don&#8217;t like how the layered-blend-mode-way makes the <a href=\"https:\/\/www.blindemanwebsites.com\/today-i-learned\/2019\/duotone\/\">duotone effect<\/a> look (see this example on <a href=\"https:\/\/codepen.io\/blindeman\/full\/wVJVJw\" target=\"_blank\" rel=\"noopener noreferrer\">Codepen<\/a>), I decided to go for a slightly different effect: one layer with a linear gradient background and a mix-blend-mode set to color. Either way though, when I checked <a href=\"https:\/\/caniuse.com\/#search=mix-blend-mode\" target=\"_blank\" rel=\"noopener noreferrer\">caniuse.com<\/a> for the support of mix-blend-mode, it turns out not to be supported by IE, Edge and in Safari and on iOS it doesn&#8217;t support the color value<strong>\u00b9<\/strong>. Worse, since it&#8217;s a layer covering the photo, if mix-blend-mode isn&#8217;t working visitors just see a gradient and no photo: it doesn&#8217;t degrade nicely. So&#8230;<\/p>\n<p><strong>What:<\/strong> @supports is a CSS query to check for feature support. It works similar to @media in that you wrap it around the block of styles you&#8217;re wishing to apply only if the feature is present (if the CSS rule you like <em>can<\/em> be applied).<\/p>\n<p><strong>Where:<\/strong> I found it as a <a href=\"https:\/\/gist.github.com\/zunairmushtaq\/aeaa48432d51cad0eb1c#gistcomment-2200311\" target=\"_blank\" rel=\"noopener noreferrer\">comment by nothrem on an IE CSS Hacks repo @ github<\/a><\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre><code class=\"css\">@support(mix-blend-mode){\r\n  div::before{\r\n    background: linear-gradient(#ebca41,#6f1683);\r\n    mix-blend-mode: color;\r\n  }\r\n}<\/code><\/pre>\n<p>And another option, which I used because of Safari and iOS, which does support mix-blend-mode but not the color value:<\/p>\n<pre><code class=\"css\">@support(mix-blend-mode: color){\r\n  div::before{\r\n    background: linear-gradient(#ebca41,#6f1683);\r\n    mix-blend-mode: color;\r\n  }\r\n}<\/code><\/pre>\n<p><strong>Thoughts:<\/strong> IE does not support the @supports query however&#8230; in IE11 at least, it also doesn&#8217;t apply the style and it doesn&#8217;t break the site, so the end result is, in this case, the same. If IE did support a feature, you couldn&#8217;t check for it this way and expect the style to be applied.<\/p>\n<p>[<em><strong>Edit:<\/strong> <strong>\u00b9<\/strong>Oddly the effect is actually showing in Safari 11.1.2 and iOS 12.3.1 (which is what I have at hand here). &#8211; 20190731<\/em>]<\/p>\n<p><strong>Read more:<\/strong> <a href=\"https:\/\/css-tricks.com\/how-supports-works\/\" target=\"_blank\" rel=\"noopener noreferrer\">@ CSS-TRICKS by Chris Coyier<\/a><\/p>\n<h3>Also, &#8230;<\/h3>\n<p>To get the most support on the gradient &#8211;although <a href=\"https:\/\/caniuse.com\/#search=linear-gradient\" target=\"_blank\" rel=\"noopener noreferrer\">linear-gradients have better support<\/a> than mix-blend-mode&#8211; I use a sweet tool called the <a href=\"https:\/\/autoprefixer.github.io\/\" target=\"_blank\" rel=\"noopener noreferrer\">Autoprefixer<\/a> that automatically adds prefixes were appropriate \ud83d\udc95<\/p>\n<hr \/>\n<div class=\"_3bJ2H CHExY\">\n<div class=\"_1l8RX _1ByhS\">Photo by <a href=\"https:\/\/unsplash.com\/@camylla93?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" target=\"_blank\" rel=\"noopener noreferrer\">Camylla Battani<\/a> on <a href=\"https:\/\/unsplash.com\/search\/photos\/question?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" target=\"_blank\" rel=\"noopener noreferrer\">Unsplash<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Alright, obviously I won&#8217;t be changing all the photos on my website whenever I change my color scheme, so giving the photos a little color in CSS would be so much nicer. And in the night I thought: just use ::before and ::after with blend modes, then you won&#8217;t need to add any HTML (so &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"@supports makes me happy\" class=\"read-more button\" href=\"https:\/\/www.blindemanwebsites.com\/today-i-learned\/2019\/supports-makes-me-happy\/#more-125\" aria-label=\"Read more about @supports makes me happy\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[24,19,23,17,21,20,22],"class_list":["post-125","post","type-post","status-publish","format-standard","hentry","category-new-things","tag-autoprefixer","tag-browser-support","tag-can-i-use","tag-css","tag-gradient","tag-mix-blend-mode","tag-tools","infinite-scroll-item"],"_links":{"self":[{"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/posts\/125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/comments?post=125"}],"version-history":[{"count":0,"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/posts\/125\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/media?parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/categories?post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/tags?post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}