1

如何将文件输入按钮放置在文本字段内的右侧这是我的小提琴 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;
 }
4

1 回答 1

3

你只是“伪造”一个边界

小提琴:http: //jsfiddle.net/TurGw/3/

html:

<form action="" method="post">
    <div class='upload-border'>
        <input type="file" name="upload"/>
    </div>
</form>

CSS:

.upload-border{
    border:1px solid black;
    width:315px;
}
input[type=file]::-webkit-file-upload-button {
    width: 0;
    padding: 0;
    margin: 0;
    -webkit-appearance: none;
    border: none;
    border:0px;
}

 x::-webkit-file-upload-button, input[type=file]:after {
    content:'Browse...';
    left: 100%;
    margin-left:3px;
    position: relative;
    -webkit-appearance: button;
    padding: 3px 8px 2px;
    border:0px;
}
于 2013-09-20T13:24:21.633 回答