【发布时间】:2016-07-16 03:46:59
【问题描述】:
我想让一张图片像一个按钮一样,当按下它时,我可以上传另一张图片。
我现在拥有的是 sn-p 中的部分,但我想让它从我的服务器中提取图像以充当按钮,然后运行一些 ajax 以不必重新加载页面然后显示图像被选中(之前的图片应该会变成被选中的那个)。
.Uploadbtn {
position: relative;
overflow: hidden;
padding: 10px 20px;
text-transform: uppercase;
color: #fff;
background: #000066;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-ms-border-radius: 4px;
-o-border-radius: 4px;
border-radius: 4px;
width: 100px;
text-align: center;
cursor: pointer;
}
.Uploadbtn .input-upload {
position: absolute;
top: 0;
right: 0;
margin: 0;
padding: 0;
opacity: 0;
height: 100%;
width: 100%;
}
<div class="Uploadbtn">
<input type="file" class="input-upload" />
<span>IMAGE</span>
</div>
【问题讨论】:
-
建议看看这个以获得复杂的解决方案:tympanus.net/codrops/2015/09/15/…
标签: javascript jquery html css ajax