CSS ::file-selector-button 伪元素
定义和用法
CSS ::file-selector-button 伪元素用于选择 <input type="file"> 类型的按钮。
实例
例子 1
设置 <input type="file"> 按钮的样式:
::file-selector-button {
border: 2px solid black;
padding: 5px 10px;
border-radius: 5px;
background-color: lightgreen;
}
例子 2
设置 <input type="file"> 按钮的样式,并添加悬停效果:
::file-selector-button {
border: 2px solid black;
padding: 5px 10px;
border-radius: 5px;
background-color: lightgreen;
}
::file-selector-button:hover {
background-color: salmon;
cursor: pointer;
}
CSS 语法
::file-selector-button {
css declarations;
}
技术细节
| 版本: | CSS Pseudo-elements Module Level 4 |
|---|
浏览器支持
表格中的数字指定了完全支持该伪元素的首个浏览器版本。
| Chrome | Edge | Firefox | Safari | Opera |
|---|---|---|---|---|
| 89 | 89 | 82 | 14.1 | 75 |
相关页面
教程:CSS 伪元素