点击之后上传图片到页面 input type="file" 样式
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test js</title>
<style>
#pic{
width:100px;
height:100px;
border-radius:50% ;
margin:20px auto;
cursor: pointer;
}
.upfile{
/*opacity: 0;*/
}
.file {
position: relative;
display: inline-block;
background: #D0EEFF;
border: 1px solid #99D3F5;
border-radius: 4px;
padding: 4px 12px;
overflow: hidden;
color: #1E88C7;
text-decoration: none;
text-indent: 0;
line-height: 20px;
}
.file input {
position: absolute;
font-size: 100px;
right: 0;
top: 0;
opacity: 0;
}
.file:hover {
background: #AADFFD;
border-color: #78C3F3;
color: #004974;
text-decoration: none;
}
</style>
</head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<body>
<div class="img_show img_show1">
<p class="p-flex">
<span class="vertical-blue"></span><span class="left-A" >水印设置</span>
<img src="" alt="" class="img-big" width="103" height="103">
<img src="" alt="" class="img-centre" width="103" height="103">
<img src="" alt="" class="img-small" width="103" height="103" >
</p>
<p class="text-blue">
<a href="javascript:;" class="file">上传水印
<input type="file" class="upfile" value="更换" class="changes" accept="image/*">
</a>
</p>
</div>
</body>
<script>
upfile = function(){
$('.img_show').each(function(){
var $this = $(this),
btn = $this.find('.upfile'),
img = $this.find('img');
btn.on('change',function(){
var file = $(this)[0].files[0],
imgSrc = $(this)[0].value,
url = URL.createObjectURL(file);
if (!/\.(jpg|jpeg|png|JPG|PNG|JPEG)$/.test(imgSrc)){
alert("请上传jpg或png格式的图片!");
return false;
}else{
img.attr('src',url);
img.css({'opacity':'1'});
}
});
});
}();
</script>
</html>
点击之后上传图片到页面 input type="file" 样式的更多相关文章
- css input[type=file] 样式美化,input上传按钮美化
css input[type=file] 样式美化,input上传按钮美化 参考:http://www.haorooms.com/post/css_input_uploadmh
- input[type='file']样式美化及实现图片预览
前言 上传图片是常见的需求,多使用input标签.本文主要介绍 input标签的样式美化 和 实现图片预览. 用到的知识点有: 1.input标签的使用 2.filelist对象 和 file对象 3 ...
- input[type=file]样式更改以及图片上传预览
以前知道input[type=file]可以上传文件,但是没用过,今天初次用,总感觉默认样式怪怪的,想修改一下,于是折腾了半天,总算是小有收获. 以上是默认样式,这里我想小小的修改下: HTML代码如 ...
- 文件上传input type="file"样式美化
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- CSS <input type="file">样式设置
这是最终想要的效果~~~ 实现很简单,div设置背景图片,<input type="file"/>绝对定位上去再设置opacity:0(透明度为0 ) 直接上代码,希望 ...
- 知识点:定义input type=file 样式的方法(转)
——“当我们想要用css美化表单的时候,有两个控件就会和前段人员作对,一个是是大名鼎鼎的select,另一个就是我现在要说说的 input type=file” 为什么要美化file控件?试想一下,别 ...
- html的文件控件<input type="file">样式的改变
一直以来,<input type="file">上传文件标签默认样式都是让人不爽的,使用它多要给它整整容什么的,当然如果用ui插件还比较方便,不能就自己来操刀实践一下! ...
- input[type=file] 样式美化,input上传按钮美化
<style>.file { position: relative; display: inline-block; background: #D0EEFF; border: 1px sol ...
- <input type="file"> change事件异常处理办法
问题:最近发现一个奇怪的bug, 那就是在上传图片需要采用input type=file来进行文件选择.由于为了适应美工的UI图,所以是把选择文件的input框隐藏了.然后通过另外一个按钮的点击事件来 ...
随机推荐
- 爬虫系列(五) re的基本使用
1.简介 究竟什么是正则表达式 (Regular Expression) 呢?可以用下面的一句话简单概括: 正则表达式是一组特殊的 字符序列,由一些事先定义好的字符以及这些字符的组合形成,常常用于 匹 ...
- 57.query phase
主要知识点: query phase步骤 query phase如何提升性能 一.query phase步骤 一次query phase一般包括以下三个步骤 The query pha ...
- 2018 noip 备战日志
我是写给自己看的…… Day1 10.8 今天开始停晚修课了,开始认真备战考试了. 今天晚上效率不错,竟然不会累,应该是平时一直这个时间写作业大脑高度集中, 现在换了编程也一样可以集中到这个状态 一些 ...
- android网络类型之2G-3G切换
在android手机‘设置’-‘移动网络类型’里可以看到有关网络类型的选项,一般默认为3G优先. 如果有需要在程序中切换网络类型的朋友,不妨试试下面的方法.这里提供了几种思路,虽然可能对待 手机的方式 ...
- CSTC 选课
选课 [问题描述] 在大学里每个学生,为了达到一定的学分,必须从很多课程里选择一些课程来学习,在课程里有些课程必须在某些课程之前学习,如高等数学总是在其它课程之前学习.现在有N门功课,每门课有个学分, ...
- 【slighttpd】基于lighttpd架构的Server项目实战(6)—预备知识之Http
接下来,我们開始http部分的开发. 在此之前.有必要先学习一下HTTP协议- http1.1 的rfc文档:http://www.ietf.org/rfc/rfc2616.txt 简单介绍 超文本传 ...
- Windows 7下Git SSH 创建Key【待解决?】
1.在桌面右键,git bash here 2.检查本机是否有ssh key设置 $ cd ~/.ssh 或cd .ssh 如果没有则提示: No such file or directory:此时需 ...
- css让文字旋转270度
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD ...
- 修改android手机文件权限
修改android手机文件权限 默认情况下,一个应用肯定是读取不了另外一个应用的数据的,因为权限不够.但是我们一定要读,怎么办? 修改我们要读取文件的权限. Android是基于Linux的,所以修改 ...
- Style contains key with bad entry
出现Style contains key with bad entry错误,检查权限是否配置好