css - 使用 bootstrap4 输入空白自定义文件

标签 css twitter-bootstrap input bootstrap-4 twitter-bootstrap-4

我正在尝试使用 bootstrap4 alpha 6 实现自定义文件输入,但添加后出现空白部分,如下所示:

<label class="custom-file">
    <input type="file" id="file" class="custom-file-input">
    <span class="custom-file-control"></span>
</label>

Bootstrap4 file browser documentation

Blank file input

我应该为这个实现添加任何 CSS 样式吗?

最佳答案

如文档中所述,占位符和按钮在 CSS 中设置:

.custom-file-control::after {
  content: "Select file...";
}

.custom-file-control::before {
  content: "Click me";
}

http://www.codeply.com/go/jcnmleDWja

此外,您还可以在 HTML 文档中使用语言声明。例如,

<html lang="en"></html>

并为每种语言设置特定的样式...

.custom-file-control:lang(en)::after {
  content: "Select file...";
}

.custom-file-control:lang(en)::before {
  content: "Click me";
}

http://www.codeply.com/go/jcnmleDWja

关于css - 使用 bootstrap4 输入空白自定义文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43422629/

相关文章:

c++ - 使用 GLFW 处理输入

javascript - 用 CSS 生成的图像替换输入字段中的文本

html - 使描述文本滑动到 div 的 100% 高度

css - Bootstrap : wrapping text

多个类的Javascript点击功能

HTML 页面高度不占屏幕的全高

jquery - 悬停后显示照片

html - svg 不支持::之后

html - "Standard"减少表列宽度以适应子元素的方法

javascript - 如何获取JQuery中存储的数据值?