同一样式表中同一字体不同字重仅700生效,求助解决方法
问题根源
你当前的核心问题是:两个不同字重的@font-face规则指向了完全相同的字体文件。Acumin Pro Condensed的常规体(400)和粗体(700)是独立设计的字体文件,浏览器无法从单个文件中解析出两种不同的字重样式,最终只会优先生效匹配到的字重(这里是700),导致400字重的设置失效。
解决方案
1. 确认字体文件完整性
确保你拥有Acumin Pro Condensed对应的两类字体文件:
- 常规体:文件名通常包含
Regular或400标识(如Acumin Pro Condensed Regular.woff2) - 粗体:文件名通常包含
Bold或700标识(如Acumin Pro Condensed Bold.woff2)
2. 修改@font-face规则
为不同字重分别指定对应的字体文件路径,修正后的代码如下:
@font-face { font-family: 'Acumin Pro Condensed'; src: url('../fonts/Acumin\ Pro\ Condensed\ Bold.woff2') format('woff2'), url('../fonts/Acumin\ Pro\ Condensed\ Bold.woff') format('woff'), url('../fonts/Acumin\ Pro\ Condensed\ Bold.ttf') format('truetype'); font-weight: 700; font-style: normal; } @font-face { font-family: 'Acumin Pro Condensed'; src: url('../fonts/Acumin\ Pro\ Condensed\ Regular.woff2') format('woff2'), url('../fonts/Acumin\ Pro\ Condensed\ Regular.woff') format('woff'), url('../fonts/Acumin\ Pro\ Condensed\ Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; } h3 { font-size: 1em; color: white; font-family: 'Acumin Pro Condensed'; font-weight: 400; text-transform: uppercase; } h2 { font-size: 1.25em; color: white; font-family: 'Acumin Pro Condensed'; font-weight: 700; }
3. 验证加载状态
通过浏览器开发者工具的「网络」面板,检查两类字体文件是否成功加载(若出现404错误,说明文件路径或文件名有误)。
额外提示
不要尝试用单个字体文件模拟不同字重(比如给400字重的元素设置font-weight:700让浏览器自动加粗),这种模拟效果会破坏字体原本的设计细节,显示效果远不如官方提供的对应字重文件。
内容的提问来源于stack exchange,提问作者ElliottMcDonald
相关产品推荐
相关产品推荐

