为什么输入文件不显示文本“浏览”?

时间:2018-08-16 20:56:37

标签: css twitter-bootstrap

我正在使用引导程序,但在文件类型的表单字段中未显示“浏览”文本,您知道为什么吗?它只会像输入文本字段一样显示输入,而没有任何“浏览”按钮。

HTML:

<div class="form-row">
  <div class="form-group col col-lg-6">
    <label for="image">Select an Image</label>
    <label class="custom-file">
      <input type="file" id="file" name="image" value="" class="custom-file-input">
      <span class="custom-file-control"></span>
    </label>
  </div>
</div>

1 个答案:

答案 0 :(得分:0)

请参见以下两个示例。问题是您使用的是custom-file-input类,而不是form-control-file

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>

<div class="form-row">
  <div class="form-group col col-lg-6">
    <label for="image">Select an Image</label>
    <label class="custom-file">
      <input type="file" id="file" name="image" value="" class="custom-file-input">
      <span class="custom-file-control"></span>
    </label>
  </div>
</div>

<form>
  <div class="form-group">
    <label for="exampleFormControlFile1">Example file input</label>
    <input type="file" class="form-control-file" id="exampleFormControlFile1">
  </div>
</form>

相关问题