Different images for light and dark modes #131
-
First of all I would like to congratulate on an awesome sphinx theme! I really love the automatic change between light and dark modes as well. For logos in the navigation menu, it is easy to setup up different images for light and dark modes. For other figures I found myself resorting to a type of hack. I would basically insert this html code with a <picture>
<source srcset="_static/logo-dark.svg" media="(prefers-color-scheme: dark)">
<img src="_static/logo-light.svg?text=Light+mode" />
</picture> |
Beta Was this translation helpful? Give feedback.
Answered by
pradyunsg
May 16, 2021
Replies: 1 comment 2 replies
-
You can set the "only-dark" and "only-light" classes on those images: .. image:: https://source.unsplash.com/200x200/daily?cute+dogs
:align: center
:class: only-light
.. image:: https://source.unsplash.com/200x200/daily?cute+cats
:align: center
:class: only-dark |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
kjelljorner
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can set the "only-dark" and "only-light" classes on those images: