summaryrefslogtreecommitdiff
path: root/content/posts/dynamic-img.md
diff options
context:
space:
mode:
Diffstat (limited to 'content/posts/dynamic-img.md')
-rwxr-xr-xcontent/posts/dynamic-img.md39
1 files changed, 39 insertions, 0 deletions
diff --git a/content/posts/dynamic-img.md b/content/posts/dynamic-img.md
new file mode 100755
index 0000000..4ae5e59
--- /dev/null
+++ b/content/posts/dynamic-img.md
@@ -0,0 +1,39 @@
1---
2title: "Dynamic Image Sources"
3date: 2020-06-13T13:20:34+05:30
4description: Using dynamic image source for dynamic CSS
5draft: false
6---
7My site uses dynamic css to generate dark or white theme based on user's system theme. So sometimes, I need to use different image colors to fit my needs. There is a very easy fix which involves using javascript but
8
9![](https://media1.tenor.com/images/ee55cce2b19a8a3731a14b0348ffe4ad/tenor.gif)
10
11(well accept for feather icons. i'll add only few icons once i get time.)
12
13## Using invert color filter in CSS
14```css
15img {
16 -webkit-filter: invert(1);
17 filter: invert(1);
18}
19```
20But sometimes it's just not the right way.
21
22## Using @media
23This is a better approach as it changes the source of the image.
24
25main.css
26```css
27<img class="class_name" src='img_light.png'/>
28```
29
30dark.css
31```css
32@media {
33 .class_name{
34 content: url(img_dark.png);
35 }
36}
37```
38
39