运行代码 缩小
汉王
HTML代码
复制 格式化 注释 注释 清空
放大
AخA
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
<html xmlns="http://www.w3.org/1999/xhtml">
3
<head>
4
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
<title>更改文本域的样式-用input模拟文本域</title>
6
<style>
7
*{margin:0;padding:0;}
8
input{border:none;border:1px solid #CCC;vertical-align:middle; }
9
.input {height:24px; line-height:24px; border-right:none; width:200px;}
10
.liulan {width:100px;height:26px;background:url(//ku.shouce.ren/files/images/201601/56a3663be7c47.jpg) no-repeat; cursor:pointer;}
11
.files{ position:absolute; left:202px; top:52px; heigth:26px;cursor:pointer;
12
         filter: Alpha(opacity=0);    
13
             -moz-opacity:0;    
14
             opacity:0;  
15
        } 
16
</style>
17
</head>
18
<body>
19
<BR>
20
<BR>
21
<BR>
22
<form method="post" action="" enctype="multipart/form-data">
23
<input type="text" id="txt" name="txt" class="input"><input type="button" onmousemove="f.style.pixelLeft=event.x-60;f.style.pixelTop=this.offsetTop;" value="浏览" size="30" onclick="f.click()" class="liulan">
24
<input type="file" id="f" onchange="txt.value=this.value" name="f" style="height:26px;" class="files"  size="1" hidefocus>
25
</form>
26
<BR>
27
<BR>
28
<BR>
29
<BR>
30
</body>
31
</html>
CSS代码
复制 格式化 注释 注释 颜色 清空
放大
CSS代码...
x
 
1
JS代码
复制 格式化 注释 注释 清空
放大
JS代码...
xxxxxxxxxx
1
 
1
名称
CSS+JS更改文件域的样式
分类
表单按钮
描述
CSS+JS更改了默认文件域的样式-用input模拟文本域,自定义功能比较强大,颜色风格都可以自己改,文本域的美化有很多例子,觉得这一款代码挺简洁的,而且美化的效果也不错,代码分享给大家。
收藏