input[type="file"]标签的美化

input[type="file"]标签的美化

1.1思路
        使用<input type="text">和 <input type="button">,分别完成Input[type=”file”]的文字显示(按钮) 与 上传文件路径的显示(文本输入框的功能)。
1.2实例
<!DOCTYPE html>
<html lang="en">
<head>  
    <meta charset="UTF-8">
    <title>修改默认的文件上传按钮</title>
    <style>
        input{ padding: 0; }
        input[type="text"]{ float: left; height: 26px; border:1px solid #ccc; }
        input[type="button"]{ float: left; width:60px; height: 28px; border:1px solid #ccc; line-height: 28px; }
        input[type="file"]{ display:none; }
    </style>
</head>
<body>
    <div class="ipt-list">
        <input type="text" name="upfile" id="upfile" readonly>
        <input type="button" value="上传" onclick="path.click()">
        <input type="file" id="path" onchange="upfile.value=this.value">
    </div>
</body>
</html>

猜你喜欢

转载自wsj123.iteye.com/blog/2398308