CSS: set font weight depending on fallback font

后端 未结 2 1882
一个人的身影
一个人的身影 2021-01-05 04:50

I am trying to set the font-weight for an element based on the font that gets chosen. For example, I may be trying to do something like this:

h1 {
    font-f         


        
相关标签:
2条回答
  • 2021-01-05 05:05

    Won't this work? Untested.

    <style>
    @font-face {
        font-family: "ArialBold";
        src: local("Arial Narrow");
        font-weight: bold;
    }
    @font-face {
        font-family: "ImpactNormal";
        src: local("Impact");
        font-weight: normal;
    }
    @font-face {
        font-family: "SansSerifBold";
        src: local("sans-serif");
        font-weight: bold;
    }
    h1 {
        font-family: ArialBold, ImpactNormal, SansSerifBold;
    }
    </style>
    

    0 讨论(0)
  • 2021-01-05 05:20

    I'm 99.99999% sure this can't be done without some serious JavaScript magic, and even with JavaScript it's damn difficult to find out which font was used in the end.

    Related: get computed font-family in JavaScript asked by yours truly

    0 讨论(0)
提交回复
热议问题