天天看点

纯CSS定义input file样式及上传图片预览 CSS

<style type="text/css">
    .upfile{cursor:pointer;direction:rtl;height:px;opacity:;width:px;filter:alpha(opacity=); position:absolute;top:;left:}
    a{
        position:relative;cursor:pointer;display:block;height:px;cursor:pointer;margin-top:px;overflow:hidden;width:px;background:#fefefe;border:px solid #dcdcdc;line-height:px;text-align:center;font-size:px;color:#333;text-decoration:none;border-radius:px;
        background:-moz-linear-gradient(center top,#ffffff,#f6f6f6 %,#f6f6f6 %,#ededed);
        background:-o-linear-gradient(top left,#ffffff,#f6f6f6 %,#f6f6f6 %,#ededed);
        background:-webkit-gradient(linear,% ,% %,from( #ffffff),to( #f6f6f6),color-stop(.,#f6f6f6),color-stop(.,#ededed));
        filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff',endColorstr='#ededed');
        -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#ffffff', endColorstr='#ededed')";
    }
    a:hover{
        background:-moz-linear-gradient(center top,#f9f9f9,#efefef %,#efefef %,#e4e4e4);
        background:-o-linear-gradient(top left,#f9f9f9,#efefef %,#efefef %,#e4e4e4);
        background:-webkit-gradient(linear,% ,% %,from( #f9f9f9),to( #efefef),color-stop(.,#efefef),color-stop(.,#e4e4e4));
        filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9',endColorstr='#e4e4e4');
        -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#f9f9f9', endColorstr='#e4e4e4')";
    }
</style>
<a href="javascript:void(0);"><input type="file" class="upfile"><span>上传图片</span></a>