<input type="file">美化效果代码实例

快乐打工仔 分类:实例代码

关于<input type="file">这里就不介绍了,大家应该都不会陌生。

但是它默认的样式实在是丑陋,难登大雅之堂,下面就分享一段代码实例,它实现了对此控件的美化效果。

代码实例如下:

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.pipipi.net/" />
<title>前端教程网</title>
<style>
.a-upload {
  padding: 4px 10px;
  height: 20px;
  line-height: 20px;
  position: relative;
  cursor: pointer;
  color: #888;
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
  display: inline-block;
  *display: inline;
  *zoom: 1
}
 
.a-upload  input {
  position: absolute;
  font-size: 100px;
  right: 0;
  top: 0;
  opacity: 0;
  filter: alpha(opacity=0);
  cursor: pointer
}
 
.a-upload:hover {
  color: #444;
  background: #eee;
  border-color: #ccc;
  text-decoration: none
}
</style>
</head>
<body>
<a href="javascript:;" class="a-upload">
  <input type="file">点击这里上传文件
</a>
</body>
</html>

回复

我来回复
  • 暂无回复内容