CSS3自定義字體
①:首先需要下載所需字體
②:把下載字體文件放入 font文件夾里,建議font文件夾與 css 和 image文件夾平級
?③:引入字體,可直接在html文件里用@font-face引入字體,分別是字體名字和路徑
例:
<style>
? ? ? ? p{
? ? ? ? ? ? width: 200px;
? ? ? ? ? ? height: 100px;
? ? ? ? ? ? margin: 40px auto;
? ? ? ? ? ? border: 1px solid black;
? ? ? ? ? ? text-align: center;
? ? ? ? ? ? font-family:'name' ;
(此處給引入字體起名)
? ? ? ? }
? ? ? ? @font-face(此處用于引用字體){
? ? ? ? ? ? font-family:'name';(注意名字相同)
? ? ? ? ? ? src: url(./);
? ? ? ? ? ? ...............
? ? ? ? }
? ? </style>
</head>
<body>
? ?<p>hello world</p >
? ?</body>
?
當我們引用很多字體時,可能不知道哪個具體生效,加載速度慢,第一時間加載不出來,最好做成圖片,速度快。
字體圖標
關于我們日常設計時需要一些圖標,苦無沒有素材,我們這里以阿里圖標庫為例。
首先引入下載好的字體圖標的css文件
我們重命名iconfont
<head>
? ? <meta charset="UTF-8">
? ? <meta name="viewport" content="width=device-width, initial-scale=1.0">
? ? <title></title>
? ? <link rel="stylesheet" href="./......">
</head>
<body>
? ?<span class="iconfont (后面這里是在阿里圖標庫font class中復制的代碼)"></span>
? ?</body>
如果我們想保留彩色的圖標:
<head>
????<meta charset="UTF-8">
????<meta name="viewport" content="width=device-width, initial-scale=1.0">
????<title>jingdong邊側欄練習</title>
????<!-- 引入css和js樣式 -->
????<link rel="stylesheet" href="./iconfont/iconfont.css">
????<script src="./ionFont/ionFont.js"></script>
????<style>
????????/* 設置樣式 */
????????.icon{
????????????width: ;
????????????height: ;
????????????fill: currentColor;
????????????overflow: hidden;
????????}
????</style>
</head>
<body>
????<!-- 照著寫就行,主要use標簽注意#后為引入圖標名稱 -->
???<svg class="icon" aria-hidden="true">
????<use xlink:href="#(阿里圖標庫中fontclass復制的代碼,注意要先下載到本地)"></use>
???</svg>
???</body>
這里再提供幾個別的圖標網站
iconfont: https://www.iconfont.cn
?iconstore:https://iconstore.co
?feathericons: https://feathericons.com
?Heroicons:https://heroicons.com
?Remix Icon: https://remixicon.com
?iconpark:https://iconpark.oceanengine.com
?Flat Icon: https://www.flaticon.com
?Css.gg: https://css.gg
?還有很多別的網站,對這個的建議是有開源的材料就用免費的,素材多的是。
?