html点击buttond出选择文件,上传,这个怎么实现?

html点击buttond出选择文件,上传,这个怎么实现?,第1张

这个样式挺漂亮的,你可以试下:

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />

<title>定义input type="file" 的样式</title>

<style type="text/css">

body{ font-size:14px}

input{ vertical-align:middlemargin:0padding:0}

.file-box{ position:relativewidth:340px}

.txt{ height:22pxborder:1px solid #cdcdcdwidth:180px}

.btn{ background-color:#FFFborder:1px solid #CDCDCDheight:24pxwidth:70px}

.file{ position:absolutetop:0right:80pxheight:24pxfilter:alpha(opacity:0)opacity: 0width:260px }

</style>

</head>

<body>

<div class="file-box">

<form action="" method="post" enctype="multipart/form-data">

<input type='text' name='textfield' id='textfield' class='txt' />

<input type='button' class='btn' value='浏览...' />

<input type="file" name="fileField" class="file" id="fileField" size="28" onchange="document.getElementById('textfield').value=this.value" />

<input type="submit" name="submit" class="btn" value="上传" />

</form>

</div>

</body>

</html>

<form action="" method="post" enctype="multipart/form-data">

<input type='file' name='textfield' id='textfield' />

<input type='button' value='浏览...' />

<input type="file" name="fileField" id="fileField" size="28" onchange="document.getElementById('textfield').value=this.value" />

<input type="submit" name="submit" value="上传" />

</form>

其中样式在分别给每一个表单元素自定义class!


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6099486.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-14
下一篇 2023-03-14

发表评论

登录后才能评论

评论列表(0条)

保存