Perintah font-face
Perintah @font-face membolehkan anda menetapkan
fon pengguna yang sumbernya
disimpan dalam fail. Fon ini kemudiannya boleh
dipasang menggunakan sifat font-family.
Sintaks
@font-face {
nama fon;
sumber untuk mencari fon;
}
Contoh
Mari cari fon pada komputer tempatan kita:
<body>
This is Montserrat SemiBold.
</body>
@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;
}
:
Contoh
Sekarang mari tentukan alamat pelayan jauh untuk mencari fon:
<body>
This is Bitstream Vera Serif Bold.
</body>
@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;
}
: