【发布时间】:2013-09-20 13:12:40
【问题描述】:
如何将文件输入按钮放置在文本字段内的右侧 这是我的小提琴 http://jsfiddle.net/cancerian73/TurGw/
这就是我想要的截图
input[type=file] {
-webkit-appearance: textfield;
position: relative;
-webkit-box-sizing: border-box;
}
input[type=file]::-webkit-file-upload-button {
width: 0;
padding: 0;
margin: 0;
-webkit-appearance: none;
border: none;
}
/* "x::-webkit-file-upload-button" forces the rules to only apply to browsers that support this pseudo-element */
x::-webkit-file-upload-button, input[type=file]:after {
content:'Browse...';
display: inline-block;
left: 100%;
margin-left:3px;
position: relative;
-webkit-appearance: button;
padding: 3px 8px 2px;
}
【问题讨论】:
-
这需要特定于 WebKit 还是什么?你有很多
-webkit-*规则,这使得这在 Firefox 中看起来完全不同。如果是这样,您可能应该在您的问题上添加一个标签。 -
@ajp15243:是的,正确的观点。从 CSS 中的注释中,我假设它仅适用于基于 Webkit 的浏览器。现在不确定:(