You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Svelte中仅为Jeju Myeongjo字体设置不同字号的实现方法

实现方案

直接调整字号类的条件判断逻辑,让text-5xl和text-2xl根据字体类型与large状态分别生效:

<span
class:font-codystar={fontFamily === "codystar"}
class:font-cormorant={fontFamily === "cormorant"}
class:font-waterfall={fontFamily === "waterfall"}
class:font-jeju-myeongjo={fontFamily === "jejuMyeongjo"}
class:text-5xl={large && fontFamily !== "jejuMyeongjo"}
class:text-2xl={large && fontFamily === "jejuMyeongjo"}
class:text-typography-light={theme === "light"}
class:text-typography-dark={theme === "dark"}
>

逻辑说明

  • 当large为true且字体不是Jeju Myeongjo时,应用text-5xl
  • 当large为true且字体是Jeju Myeongjo时,应用text-2xl
  • 若large为false,两个字号类都不会被添加

内容的提问来源于stack exchange,提问作者Kiju Shin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 01:31:03