首页 > 解决方案 > Poppins @import 无法正常工作的外部样式问题

问题描述

我正在制作一个非常简单的索引页面,并试图合并一些特定的字体。我的目标是@import从 Google API URL Poppins,然后使用*选择器将其添加到每个元素。我的CSS如下:

@import url('https://fonts.googleapis.com/css?family=Poppins');


* {
    margin: 0;
    padding: 0;
    font-family: 'Poppins';
}

但是,当我这样做时,字体在默认的无衬线字体中保持完全相同。在其他一些帖子之后,(字体系列“Poppins”在加载时无法在我的网站上正常工作)我在我的 html 中执行了此操作:

<!DOCTYPE html>
<html>
<head>
    <title>Wavy Section SVG</title>
    <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
            font-family: 'Poppins';transition: 
        }
    </style>
</head>
<body>
    <h2>Text</h2>
</body>
</html>

然后完美地工作,允许文本是 Poppins 而不是 sans-serif。我知道这可能有点迂腐,但我不想要内部造型。为什么我的@import标签不起作用?感谢您的回答!

标签: cssimportfonts

解决方案


用正文替换 *

body {
font-family: 'Poppins';
}

推荐阅读