BootStrap4-fileinput 小图标无法显示:

BootStrap4-fileinput 小图标无法显示:

如下图

在这里插入图片描述

一、出现这种情况的原因?

从Bootstrap4后图标开始收费,文件中不再提供免费的图标。图标分离。

二、具体解决办法(HbuilderX和idea均有)

首先:bootstrap4以上版本相对于3,在bootstrap.css中缺少图标样式代码,同时减掉了提供样式依赖的fonts文件夹,如下:

在这里插入图片描述
在这里插入图片描述

以下为可以运行后的完整文件:具体一一说明:

!](https://img-blog.csdnimg.cn/20201013105219839.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1d1X2xlYXJuZXI=,size_16,color_FFFFFF,t_70#pic_center)

1.首先第一步

一、在bootstrap.min.css文件末尾粘贴缺少的图标样式代码:(代码在文章末尾,自行复制)

二、将Bootstrap3中的fonts文件夹整体复制出来,fonts文件和bootstrap下的css文件并列,如上面我截图的目录结构。

三、需要引入的文件
在这里插入图片描述

fileinput文件夹中缺少的css和js文件 下载地址

2.HbuilderX中

目录结构:

在这里插入图片描述

newfile.html:
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
				<link rel="stylesheet" href="../css/bootstrap.min.css" />
				<link rel="stylesheet" href="../css/fileinput.min.css" media="all" rel="stylesheet" type="text/css"/>
				<!-- <link rel="stylesheet" href="../css/theme.min.css" /> -->
				<script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script>
				<script type="text/javascript" src="../js/fileinput.min.js" type="text/javascript"></script>
				<script type="text/javascript" src="../js/bootstrap.min.js" type="text/javascript"></script>
				<script type="text/javascript" src="../js/zh.js" type="text/javascript"></script>
				<!-- <script type="text/javascript" src="../js/theme.min.js" type="text/javascript"></script> -->
				
	</head>
	<body>
		
		<input  id="uploadImg" type="file" class="file" />
		<i class="fas fa-camera"></i>
		
		<!-- language:"zh"需要引入指定的js文件,uploadUrl,在预览图片时多上传和删除的小图标 -->
			<script type="text/javascript">
				initFileInput();
				function initFileInput(){
    
					$("#uploadImg").fileinput({
    
						language: 'zh',
						dropZoneTitle: '可以将图片拖放到这里。。支持多文件上传',
						showUpload: false,
						uploadUrl: "/...",
						browseClass: "btn btn-primary",
						
					})
				}
			</script>
	</body>
</html>

3.代码补充

bootstrap4中bootstrap.min.css缺少的代码如下:

@font-face {
   
  font-family: 'Glyphicons Halflings';

  src: url('../fonts/glyphicons-halflings-regular.eot');
  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
.glyphicon {
   
  position: relative;
  top: 1px;
  display: inline-block;
  font-family: 'Glyphicons Halflings';
  font-style: normal;
  font-weight: normal;
  line-height: 1;

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.glyphicon-asterisk:before {
   
  content: "\002a";
}
.glyphicon-plus:before {
   
  content: "\002b";
}
.glyphicon-euro:before,
.glyphicon-eur:before {
   
  content: "\20ac";
}
.glyphicon-minus:before {
   
  content: "\2212";
}
.glyphicon-cloud:before {
   
  content: "\2601";
}
.glyphicon-envelope:before {
   
  content: "\2709";
}
.glyphicon-pencil:before {
   
  content: "\270f";
}
.glyphicon-glass:before {
   
  content: "\e001";
}
.glyphicon-music:before {
   
  content: "\e002";
}
.glyphicon-search:before {
   
  content: "\e003";
}
.glyphicon-heart:before {
   
  content: "\e005";
}
.glyphicon-star:before {
   
  content: "\e006";
}
.glyphicon-star-empty:before {
   
  content: "\e007";
}
.glyphicon-user:before {
   
  content: "\e008";
}
.glyphicon-film:before {
   
  content: "\e009";
}
.glyphicon-th-large:before {
   
  content: "\e010";
}
  • 12
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值