css - 如何根据媒体查询有效地使用不同的字体权重
问题描述
当屏幕大小改变时,谷歌字体粗细不会改变。这是使用@import 更改小屏幕中字体粗细的正确方法还是有其他方法?
h1{
font-family: 'Montserrat',sans-serif;
font-size: 50px;
}
@media only screen and (max-width: 480px)
{
@import url('https://fonts.googleapis.com/css?family=Montserrat:600');
h1{
font-size:20px;
font-weight:900;
} }
<!-- Google Font in Html-->
<link href="https://fonts.googleapis.com/css?family=Montserrat:100" rel="stylesheet">
<h1> This is a text </h1>
解决方案
写谷歌字体@import url(' https://fonts.googleapis.com/css?family=Montserrat:600 '); 在 css 文件的顶部,该部分不需要它,然后尝试。如果发生同样的问题,则使该属性变得重要。Like Font-weight:900 !important
推荐阅读
- mysql - mySQL 根据评论数量找到前 3 个帖子
- powerapps - 在 PowerApps 门户中显示 Dataverse 图像
- apache-kafka - Kafka Ignite Sink Connector - Ignite 的配置文件
- ios - 在 SwiftUI 中按日期分组
- javascript - 从 nginx 服务器获取 pdf 或 csv 下载的 href url 链接
- python-3.x - Discord.py 检测已删除消息不起作用
- php - 从 Live Hosted Server 到本地 XAMPP 的网站备份失败
- android - 在 Android 中以编程方式创建 URL 快捷方式
- flutter - 如何使 SliverGrid 居中?
- python-3.x - 在定义了“with”语句的类中多次尝试使用相同的 SUIT