Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS Responsive image both light and dark mode

Jenner

Coder
Good morning!

I'm hoping someone can help me with something. I've been tasked with creating an email signature template for my company and have been hard at work custom crafting a block of HTML-CSS that works and looks good in all conditions... Light mode... Dark mode... standard displays... high resolution displays where everything needs to be scaled 2x to avoid being microscopic...
My problem is with the company logo. It's not a logo that does well in both light/dark environments, and we have an actual "dark mode" logo that we use for screen printing on black shirts, etc. Likewise, I need to make it a responsive image because on the screens of most modern smartphones and Microsoft Surface tablets where the dpi scaling is set for 2x, my raster image isn't scaling with it.

I can't get it to work at all. I've tried and tried but in every instance, I can only seem to get the default "src" image to load.
Below is the code I'm using (the key parts I believe... I can post the whole thing if needed):

HTML:
<meta name="color-scheme" content="light dark">
<meta name="supported-color-schemes" content="light dark">
<picture>
    <source srcset="http://www.mycompany.com/images/logo-dark-10.png 1x, http://www.mycompany.com/images/logo-dark-15.png 1.5x, http://www.mycompany.com/images/logo-dark-20.png 2x" media="(prefers-color-scheme: dark)">
    <source srcset="http://www.mycompany.com/images/logo-light-10.png 1x,http://www.mycompany.com/images/logo-light-15.png 1.5x, http://www.mycompany.com/images/logo-light-20.png 2x" media="(prefers-color-scheme: light)">
    <img  src="http://www.mycompany.com/images/logo-light-10.png" alt="My Company" border="0">
</picture>

I'm not a web-coder by any means. I know enough to be dangerous and my day job is a network administrator and .NET applications programmer. If anyone sees anything blatantly stupid that I'm doing, please tell me. I've scoured the internet looking for an example of a light/dark mode raster image made "responsive" to various screen PPIs and scaling.
As I mentioned. In all cases, only the "SRC=...logo-light-10.png" image is loading, regardless of which email client, web browser, screen or light/dark environment I'm using it in.

Thank you for your time.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom