答案 0 :(得分:3)
这是你如何做到的!步骤进行:
<input type=file>
上传文件。但我们实际上并没有展示它。button
并将所有点击重定向到我们的<input type=file>
。<input type=file>
更改其值时,我们都会在span
中显示。以下与图片类似,尽可能接近。
.browse-field {
position: relative;
display: inline-block;
font-family: Arial, sans-serif;
font-size: 15px;
color: #999;
border-radius: 5px;
border: 1px solid #CACACA;
background-image: linear-gradient(rgba(0,0,0,0.15), transparent 13%);
}
.browse-field>input[type=file] { display: none; }
.browse-field .file {
display: inline-block;
margin: 0 0 0 0.8em;
min-width: 25ch; /* Modify as needed! */
}
.browse-field .btn {
margin: 6px 9px;
padding: 5px 14px;
outline: none;
border: none;
border-radius: 4px;
background: #CACACA;
color: #FFF;
font: inherit;
}
/* Modify the following styles as desired */
.browse-field .btn:hover { background: #DADADA; }
.browse-field .btn:active { background: #CACACA; }
.browse-field .btn:focus { box-shadow: 0 0 0 2px rgba(0,0,0,0.1); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(function(){
$(".browse-field>input[type=file]").each(function(){
var inpfile = $(this);
inpfile.change(function(){
inpfile.siblings(".file").text(this.value)
})
inpfile.siblings(".btn").click(function(){
inpfile.click();
})
})
})
</script>
<div class=browse-field>
<input type=file>
<span class=file>No file selected.</span>
<button class=btn>Browse</button>
</div>
答案 1 :(得分:0)
查看此网站:http://css3buttongenerator.com 它可以帮助您创建链接中的按钮。
答案 2 :(得分:0)
我想你需要这个吗?小便:click
<div>
<form>
<input type="text" name=""/>
<input type="submit" value="Submit" class="button"/>
</form>
</div>
Css
form input {
border:0px;
margin:0px;
padding:0px;
}
form .button{
padding:5px;
border-radius:3px;
}
div {
border:1px solid #B2B2B2;
border-radius:3px;
width:33%;
height:auto;
padding:5px;
}