简体   繁体   中英

New To HTML & CSS | How Can I Add A Custom Font From My Laptop?

I'm new to CSS and i'm not sure how to add a custom font. I've tried searching everywhere on Stackflow and cannot find an answer.

@font-face{
    font-family: "Athelas";
    src: url('Athelas.ttf') format("truetype");
    font-style: normal;
    font-weight: normal;
}

body{
    background: rgb(2,0,36);
    background: linear-gradient(137deg, rgba(2,0,36,1) 0%, rgba(9,9,121,1) 35%, rgba(0,212,255,1) 100%);
    background-attachment: fixed;
}

.center{
    text-align: center;
    font-size: 90px;
    font-family: "Athelas";
}

Note: I'm Used To Developing In LUA Via Roblox And I'm New To Stackflow

You can specify the src to be local, for example: src: local("Ubuntu Light")

From MDN docs :

If the local() function is provided, specifying a font name to look for on the user's computer, and the user agent finds a match, that local font is used.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM