Font-face komandası

@font-face komandası istifadəçiyə faylda saxlanılan mənbəyi olan şrifti təyin etməyə imkan verir. Bu şrift daha sonra font-family xüsusiyyəti ilə qoşula bilər.

Sintaksis

css@font-face {
  şriftin adı;
  şriftin axtarış mənbəyi;
}

Nümunə

Gəlin lokal kompüterimizdə bir şrift tapaq:

html<body>
  This is Montserrat SemiBold.
</body>
css@font-face {
  font-family: "Montserrat SemiBold";
  src: local("Montserrat SemiBold");
}
  
body {
  font-family: "Montserrat SemiBold";
}

#elem {
  animation: anim 3s infinite;
  border: 1px solid black;
  width: 50px;
  height: 50px;
}

Результат:

Nümunə

İndi isə şriftin axtarışı üçün uzaq serverin ünvanını göstərək:

html<body>
  This is Bitstream Vera Serif Bold.
</body>
css@font-face {
  font-family: "Bitstream Vera Serif Bold";
  src: url("https://mdn.github.io/css-examples/web-fonts/VeraSeBd.ttf");
}
  
body {
  font-family: "Bitstream Vera Serif Bold", serif;
}

#elem {
  animation: anim 3s infinite;
  border: 1px solid black;
  width: 50px;
  height: 50px;
}

Результат: