今天用bootstrap发现字体图标失效,网上找了很多但没有满意的答案没法,自己动手呗
第一,Bootstrap4字体图标已经被分离出来,所以要下载它的字体图标文件连接
第二,用法实例如下
<svg class="bi" width="32" height="32" fill="currentColor">
<use xlink:href="bootstrap-icons.svg#heart-fill"/>
</svg>
看见上面的href没有就是它那个字体图标文件下载解压后拷贝进项目中,你在哪里用bootstrap4的js,css下面建立一个font文件然后将拷贝过来的svg格式的文件放到里面,说到这里你没猜错就是href里面的bootstrap-icons.svg#heart-fill中的bootstrap-icons.svg#是固定格式,你要啥图标在后面加比如bootstrap-icons.svg#eye,还在bootstrap-icons.svt#eye前加上路径,相对路径,实例如下:
<svg class="bi" width="32" height="32" fill="currentColor">
<use xlink:href="../boot/font/bootstrap-icons.svg#heart-fill"/>
</svg>
还有一种是外连式,类似于如下的
<svg class="bi bi-chevron-right" width="32" height="32" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M6.646 3.646a.5.5 0 01.708 0l6 6a.5.5 0 010 .708l-6 6a.5.5 0 01-.708-.708L12.293 10 6.646 4.354a.5.5 0 010-.708z"/></svg>