首页 > 解决方案 > 在引导程序上使用 btn-outline 输入文件

问题描述

我有一个引导表单,其中有一个输入文件,但我希望它具有 btn-outline-info 的设计,所以我这样做:

 <div class="btn btn-outline-info btn-lg">
     <input id="signedAgreementFile" type="file" class="form-control-file">
  </div>

所以我有一个“选择文件”按钮,旁边有一个字符串:蓝色的“无文件选择”,它们都在一个蓝色框中:

在此处输入图像描述

当我将它悬停时,按钮变为蓝色,文本变为白色: 在此处输入图像描述

直到这里一切顺利。但是当我上传文件时,文件名替换“无文件选择”但始终保持白色:

在此处输入图像描述

在此处输入图像描述

我不知道为什么以及如何纠正它。我什至无法访问 HTML 中的此文本。

标签: htmlcssinputbootstrap-4

解决方案


尝试这个?

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">


<div class="btn btn-outline-info btn-lg">
  <input id="signedAgreementFile" type="file" class="form-control-file" onchange="this.style.color='#17a2be'">
</div>


推荐阅读