由于在bootstrap4中默认不提供字体,这里记录下整个的使用过程。分为四个步骤:下载文件,拷贝文件,引用css文件,使用样式;

下载文件

首先我们要下载bootstrap4的压缩包以及font-awesome图标文件。

如果下载失败,可使用我下载好的文件:链接: https://pan.baidu.com/s/1KiBiVYhsqpVR_rTbLaV3PA 提取码: 5f3z

拷贝文件

下载好的目录结构如下:

移动方法:

1.把左边的css中的文件放到右边的css文件夹中;

2. 把左边的font文件夹移动到右边的目录(bootstrap-4.5.0-dist)里;

3. 把bootstrap-4.5.0-dist拷贝到自己的项目中;

4. 把jquery.zip解压后的文件夹放入(bootstrap-4.5.0-dist)中;

引用css文件

假设你的html文件和bootstrap-4.5.0-dist在同级目录,引用方法如下:

    <link rel="stylesheet" href="./bootstrap-4.5.0-dist/css/bootstrap.css">
    <link rel="stylesheet" href="./bootstrap-4.5.0-dist/css/font-awesome.min.css">

 使用样式

如:使用手机图标(icon-mobile-phone)和下三角标(icon-caret-down)。

完整的图标列表:https://www.bootcss.com/p/font-awesome/#

完整HTML代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>易学教育-IT人的自我成长中心</title>
    <link rel="stylesheet" href="./bootstrap-4.5.0-dist/css/bootstrap.css">
    <link rel="stylesheet" href="./bootstrap-4.5.0-dist/css/font-awesome.min.css">
<style>
body{
    font-size: 13px;
    font-family: "Bitstream Vera Sans Mono", Monaco, "Courier New", Courier, monospace;
    color: #000;
}

.top-bar{
    background-color: red;
}
</style>
</head>
<body>
<header id="yx-header">
    <div class="top-bar">
        <div class="container">
            <div class="row">
                <div class="top-bar-1">
                    <a href="">
                        <i class="icon-mobile-phone"></i>
                        <span>关注微信号</span>
                        <span class="icon-caret-down"></span>
                    </a>
                </div>
            </div>
        </div>
    </div>
</header>

<script src="./bootstrap-4.5.0-dist/jquery/jquery-3.5.1.js"></script>
</body>
</html>

 

福利:为了防止小伙伴拷贝出错了,这里列出完整的代码:

链接: https://pan.baidu.com/s/1u0jz9HbpIKDht5UqbGrCDA 提取码: qab7