m5k1umn 发表于 2024-7-30 23:02:51

零基本教你学前端——66、CSS谷歌字体和Icon图标


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">咱们</span>学习CSS谷歌字体和CSS Icon 图标。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">咱们</span>在应用 font-family 属性声明样式字体时,除了<span style="color: black;">运用</span>HTML中的标准字体外,还<span style="color: black;">能够</span><span style="color: black;">运用</span>谷歌字体。谷歌字体是免费<span style="color: black;">运用</span>的,并且有1000多种字体可供<span style="color: black;">选取</span>。<span style="color: black;">咱们</span>再<span style="color: black;">亦</span><span style="color: black;">不消</span>担心用户电脑上<span style="color: black;">是不是</span>安装某个字体了。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">要<span style="color: black;">运用</span>谷歌字体,只要在&lt;head&gt;元素里添加一个特殊的样式表链接,就<span style="color: black;">能够</span>在CSS里<span style="color: black;">运用</span>了。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">创建一个 font-google-icons.html 文件,构建好<span style="color: black;">基本</span>代码,添加一个 h1 元素,三个 p 元素。填入<span style="color: black;">有些</span>文本。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在 head 元素里添加 link 元素,href属性值为 google api 的 css <span style="color: black;">位置</span> (https://fonts.googleapis.com/css )。 在css 后边,加一个问号 (?),定义属性 family 等于一个字体名<span style="color: black;">叫作</span>,<span style="color: black;">例如</span> Sofia。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">再创建一个 mystyle-3.css 文件,定义 body <span style="color: black;">选取</span>器,声明样式 font-family,值为引号 Sofia,逗号 serif。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">body {</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">font-family: "Sofia", serif;</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">}</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在页面里引入这个样式文件。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在浏览器里查看效果,所有的文字都应用了 Sofia 这个字体。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">要<span style="color: black;">运用</span>多个谷歌字体,只需用管道字符竖线(|)分隔字体名<span style="color: black;">叫作</span>。修改一下样式表链接的字体为Audiowide,竖线,Sofia,竖线,Trirong (Audiowide|Sofia|Trirong )(查效果看网址:https://fonts.googleapis.com/css?family=Sofia&amp;effect=neon|outline|emboss|shadow-multiple)</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">给三个 p 元素都定义 class 属性,值分别为 a,b,c。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在样式里,定义 p.a <span style="color: black;">选取</span>器,声明样式:font-family: "Audiowide", sans-serif。定义 p.b <span style="color: black;">选取</span>器,声明样式 font-family: "Sofia", sans-serif。定义 p.c <span style="color: black;">选取</span>器,声明样式 font-family: "Trirong", serif。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">咱们</span>看,三个段落应用了<span style="color: black;">区别</span>的字体。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">谷歌字体除了引用<span style="color: black;">区别</span>的字体外,还<span style="color: black;">能够</span>随心所欲添加字体的样式。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在链接的字体后面添加一个 &amp;(读作 and) 符号,定义 effect 等于 fire。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">再给 h1 添加一个 class 属性,值为 font-effect-fire。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">咱们</span>看,标题燃起来火焰!</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">当然,和引用字体<span style="color: black;">同样</span>,<span style="color: black;">亦</span><span style="color: black;">能够</span><span style="color: black;">经过</span>管道符竖线(|),引入多个效果。<span style="color: black;">例如</span>把 effect 的值改为 neon,竖线,outline,竖线,fire,竖线,shadow-multiple。(neon|outline|fire|shadow-multiple)</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">给三个P标签分别添加class属性,值分别是font-effect-neon\font-effect-outline\font-effect-shadow-multiple</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">再看一下效果,太酷炫了!</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">除了谷歌字体,还<span style="color: black;">能够</span><span style="color: black;">经过</span><span style="color: black;">运用</span>一个图标库,很容易地将图标添加到<span style="color: black;">咱们</span>的HTML页面中。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">首要</span>给<span style="color: black;">大众</span>介绍一个图标库网站,fontawesome.com (读作 fontawesome 点 com),点击 sign in 图标。<span style="color: black;">倘若</span><span style="color: black;">无</span>账号,点击 sign up,注册一个。输入一个你的邮箱<span style="color: black;">位置</span>,点击发送验证邮件。进入到你的邮箱,打开邮件,点击一下验证按钮。输入<span style="color: black;">秘码</span>,再次输入相同的<span style="color: black;">秘码</span>。点击按钮。<span style="color: black;">能够</span>输入<span style="color: black;">有些</span>个人信息,当然<span style="color: black;">亦</span><span style="color: black;">能够</span>跳过。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">此时,点击 "Copy Kit Code" 按钮,复制左边这段代码。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">回到<span style="color: black;">咱们</span>的 html 页面,在 link 下面右键粘贴。大功告成!接下来就<span style="color: black;">能够</span><span style="color: black;">运用</span>图标了。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在页面里三个段落的开头,添加三个 i 元素,<span style="color: black;">所有</span>定义 class 属性,值分别为 fas fa-cloud(<span style="color: black;">重视</span>中间有空格,要读出来),fas fa-heart,fas fa-car。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">瞧瞧</span>效果,你会<span style="color: black;">发掘</span><span style="color: black;">每一个</span>段落的<span style="color: black;">起始</span>都添加了一个小图标。<span style="color: black;">更加多</span>的图标,<span style="color: black;">大众</span><span style="color: black;">能够</span><span style="color: black;">拜访</span>这个<span style="color: black;">位置</span>获取。 (https://fontawesome.com/icons)</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">你可能会想,我用<span style="color: black;">照片</span><span style="color: black;">同样</span><span style="color: black;">能够</span>实现呀!Icon字体图标的强大之处<span style="color: black;">便是</span>,你<span style="color: black;">能够</span>将这个图标当成是文本,任意的添加样式。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">给心形的图标 i 元素定义一个 style 属性,值为 color: red。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">你会惊喜的<span style="color: black;">发掘</span>,图标变<span style="color: black;">成为了</span>红色!<span style="color: black;">倘若</span><span style="color: black;">运用</span> img,<span style="color: black;">咱们</span>得引入<span style="color: black;">另一</span>一个<span style="color: black;">照片</span>文件了。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">字体图标在网站<span style="color: black;">研发</span>中非常有用,后续的课程,<span style="color: black;">咱们</span>还会更深入的<span style="color: black;">科研</span>他。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">文案</span>配套视频链接:</p>https://www.bilibili.com/video/BV1oU4y1278g?p=66




听听海 发表于 2024-9-1 04:38:30

i免费外链发布平台 http://www.fok120.com/

4zhvml8 发表于 2024-9-27 02:00:23

你说得对,我们一起加油,未来可期。

nqkk58 发表于 2024-9-29 00:01:56

楼主听话,多发外链好处多,快到碗里来!外链论坛 http://www.fok120.com/

nykek5i 发表于 2024-10-13 21:27:11

回顾历史,我们感慨万千;放眼未来,我们信心百倍。
页: [1]
查看完整版本: 零基本教你学前端——66、CSS谷歌字体和Icon图标