YunYouJun

GitHub 根据浏览器亮暗皮肤加载对应图标,是如何实现的?

  •  
  •   YunYouJun ·
    YunYouJun · Apr 9, 2020 · 2197 views
    This topic created in 2257 days ago, the information mentioned may be changed or developed.

    上周还是什么时候,突然发现 GitHub 的图标可以根据浏览器的亮暗加载对应相反色的图标。

    譬如,亮色时加载黑圆圈,暗色时加载白圆圈。

    image.png

    请问这是怎么做到的?

    头部目前看到应该相关的是这个。

    <link rel="alternate icon" class="js-site-favicon" type="image/png" href="https://github.githubassets.com/favicons/favicon-dark.png">
    <link rel="icon" class="js-site-favicon" type="image/svg+xml" href="https://github.githubassets.com/favicons/favicon-dark.svg">
    
    
    4 replies    2020-04-09 04:12:03 +08:00
    ysc3839
        1
    ysc3839  
       Apr 9, 2020 via Android
    js 设置的吧?
    iasuna
        2
    iasuna  
       Apr 9, 2020 via iPhone   ❤️ 3
    在 v2 上发帖❌
    谷歌搜索✓

    https://css-tricks.com/dark-mode-favicons/
    dcalsky
        3
    dcalsky  
       Apr 9, 2020 via Android
    v2 啥时候能学学 github 根据我手机壳的颜色改变主题色。
    YunYouJun
        4
    YunYouJun  
    OP
       Apr 9, 2020 via Android
    @iasuna !感谢。我的确谷歌了,可能是关键词没找好。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2545 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 15:49 · PVG 23:49 · LAX 08:49 · JFK 11:49
    ♥ Do have faith in what you're doing.