How to set different font-weight for fallback font?

前端 未结 2 1117
情书的邮戳
情书的邮戳 2021-02-15 13:53

I\'ve came across a problem with custom font i use for my website.

So i use following CSS for text.

font-family: \"Open Sans\",Helvetica,Arial;
font-wei         


        
2条回答
  •  情深已故
    2021-02-15 14:05

    Unfortunately, there is no way to define fallback font specific styling using CSS alone.

    As such you may want to attempt to work out the font being used, then apply a style as a result, see here for one method which works out the width resulting from applying a font to an element before 'best guessing' which it is.

    That said, it is essentially a hack/workaround.

    Otherwise, you could look into implementing a method to identify where the symbols are and then wrap them in styles span tags, again this would be a fairly dirty hack as opposed to a clean solution.

提交回复
热议问题