如何使用Bootstrap 5更改选择文件和文本 [英] How to change "Choose file" text using Bootstrap 5

查看:0
本文介绍了如何使用Bootstrap 5更改选择文件和文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否无法使用类似于Bootstrap 4的CSS更改Bootstrap 5中输入文件的Choose文件文本?

以及如何向";未选择文件添加页边距?

推荐答案

Bootstrap 5 Beta版不再提供使用伪元素覆盖browser's file input defaultscustom file input like Bootstrap 4。因此,您必须使用JS或创建自己的psuedo元素来隐藏Choose file..输入区域...

数据-lang="js"数据-隐藏="假"数据-控制台="真"数据-巴贝尔="假">
#formFile::before {
  content: "Pick file";
  position: absolute;
  z-index: 2;
  display: block;
  background-color: #eee;
  width: 80px;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<div class="container min-vh-100 py-2">
  <div class="row">
    <div class="col">
      <div class="mb-3">
        <input class="form-control" type="file" id="formFile">
      </div>
    </div>
  </div>
</div>

这篇关于如何使用Bootstrap 5更改选择文件和文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆