Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Set CSS value in HTML to reflect current theme #192

Open
@vsajip

Description

@vsajip

Seethis page, where the anchor points to an SVG. If you ensure that there's no theme in local storage for this page, then if the browser settings are used to switch between dark and light modes (I'm using Firefox), the SVG is styled appropriately to display correctly. However, if I use the theme selector on the page to select dark mode when the browser is set to light mode, the SVG does not display correctly.

The reason is that I style for light mode and use a media query to override some styles, using@media (prefers-color-scheme: dark). However, when the theme selector is used to select dark mode, then some dark-mode CSS is pulled in using theactivateTheme() JS function, but from what I can tell this leaves no trace in the markup that we're now in dark mode. If there were e.g. adark-theme class added to the<body> tag when the page is in dark mode, then I could duplicate the styling using an appropriate selector. My complete styling of the SVG is:

svg {background-color: transparent!important;    }line {stroke:#000000;fill: none;stroke-opacity:1;    }polygon,rect {fill: none;stroke:#000000;fill-opacity:1;stroke-opacity:1;    }polygon.filled {fill:#ff0000;    }polyline {fill: none;stroke-opacity:1;stroke:#000000;    }text {fill:#000000;fill-opacity:1;stroke: none;font-family: sans-serif;font-style: normal;font-weight: normal;text-anchor: start;    }@media (prefers-color-scheme: dark) {/* could duplicate this styling if body.dark-theme */polygon,rect,polyline,line {stroke:#ffffff;      }text {fill:#ffffff;      }    }

If there is another approach I could use to achieve the desired result (proper styling of the SVG in all cases), please let me know. Otherwise, would you consider adding dark-theme class to thebody or other container tag so that I could try and achieve the desired result? Or have I missed somewhere where such a class has been added?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp