-webkit-filter是css3的一个属性,Webkit率先支持了这几个功能,感觉效果很不错。一共有10种最基本的特效,下来这个DEMO很好的展示了这些效果:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>css3属性 filter</title>
<style>
*{padding: 0; margin: 0;}
.imgbox{width: 860px;margin: 20px auto; height: 256px;}
img{display: block; width: 410px; float: left; }
img:last-of-type{float:right;}
.box{width: 860px;margin: 0 auto; }
input[type="button"]{font-size: 14px;padding: 10px 12px;border:none;}
input[type="button"].hover,input[type="button"]:hover{background: #2BA5D3;color: #fff;}
.inner{width: 860px;text-align: center;margin: 0 auto;padding: 0 0 20px 0;font-size: 20px;font-family: 'microsoft yahei'}
</style>
<script>
window.onload=function(){
var img=document.querySelectorAll('img')[1];
var btn=document.querySelectorAll('input');
var div=document.querySelector('.inner');
img.style.WebkitFilter='grayscale(0.8)';
div.innerHTML='grayscale:灰度,值为0-1之间小数';
for(var i=0; i<btn.length;i++){
btn[i].onclick=function(){
switch(this.value) {
case 'grayscale':
img.style.WebkitFilter='grayscale(0.8)';
break;
case 'sepia':
img.style.WebkitFilter='sepia(0.8)';
break;
case 'saturate':
img.style.WebkitFilter='saturate(50)';
break;
case 'hue-rotate':
img.style.WebkitFilter='hue-rotate(90deg)';
break;
case 'invert':
img.style.WebkitFilter='invert(0.3)';
break;
case 'opacity':
img.style.WebkitFilter='opacity(0.2)';
break;
case 'brightness':
img.style.WebkitFilter='brightness(0.8)';
break;
case 'contrast':
img.style.WebkitFilter='contrast(210)';
break;
case 'blur':
img.style.WebkitFilter='blur(5px)';
break;
case 'drop-shadow':
img.style.WebkitFilter='drop-shadow(10px 10px 5px #aaa)';
break;
}
div.innerHTML=this.value+':'+this.getAttribute('data-info');
} }
}
</script>
</head>
<body>
<div class="imgbox" id="imgBox">
<img src="http://img.ivsky.com/img/tupian/pre/201509/08/caoyuanshang_wanxia-005.jpg">
<img src="http://img.ivsky.com/img/tupian/pre/201509/08/caoyuanshang_wanxia-005.jpg">
</div>
<div class="inner"></div>
<div class="box">
<input type="button" value="grayscale" data-info="灰度,值为0-1之间小数">
<input type="button" value="sepia" data-info="褐色,值为0-1之间小数">
<input type="button" value="saturate" data-info="饱和度,值为num">
<input type="button" value="hue-rotate" data-info="色相,值为0-360之间的色轮数">
<input type="button" value="invert" data-info="反色,值为0-1之间小数">
<input type="button" value="opacity" data-info="不透明度,值为0-1之间小数">
<input type="button" value="brightness" data-info="亮度,值为0-1之间小数">
<input type="button" value="contrast" data-info="对比度,值为num">
<input type="button" value="blur" data-info="模糊,值为length">
<input type="button" value="drop-shadow" data-info="阴影,同box-shadow写法">
</div> </body>
</html>

用法是标准的CSS写法,如:-webkit-filter: blur(2px);关于浏览器的支持,在caniuse.com 里可以看到,除开ie有及Opea min不支持以外,其它浏览器都可以良好的支持;但是需要注意的是,为了避免出现兼容问题,还是应该加上各大浏览器的私有前缀;如-webkit,-moz;上面这个demo,只是兼容了webkit,浏览的时候,需在chrome里面运行;

CSS3 filter10种特效整理的更多相关文章

  1. 《基于JQuery和CSS的特效整理》系列分享专栏

    <基于JQuery和CSS的特效整理>已整理成PDF文档,点击可直接下载至本地查阅https://www.webfalse.com/read/201724.html 文章 一款基于jQue ...

  2. css3 animation动画特效插件的巧用

    这一个是css3  animation动画特效在线演示的网站 https://daneden.github.io/animate.css/ 下载 animate.css文件,文件的代码很多,不过要明白 ...

  3. jQuery+turn.js翻书、文档和杂志3种特效演示

    很好用的一款插件jQuery+turn.js翻书.文档和杂志3种特效演示 在线预览 下载地址 实例代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML ...

  4. 【AS3】Flash与后台数据交换四种方法整理

    随着Flash Player 9的普及,AS3编程也越来越多了,所以这次重新整理AS3下几种与后台数据交换方法.1.URLLoader(URLStream)2.FlashRemoting3.XMLSo ...

  5. 在C#里实现各种窗口切换特效,多达13种特效

    原文:http://www.cnblogs.com/clayui/archive/2011/06/28/2092126.html 预览:   下载 这次clayui给大家带来了比较实用的东西,因为时间 ...

  6. 可控制转速CSS3旋转风车特效

    以前制作网页动画一般使用javascript,现在已经有越来越多动动画使用纯CSS实现,并且动画的控制也可以使用CSS3实现,因为CSS 3来了,CSS 3的动画功能确实强大.以下是一个纯CSS3制作 ...

  7. 在WebBrowser中执行javascript脚本的几种方法整理(execScript/InvokeScript/NavigateScript) 附完整源码

    [实例简介] 涵盖了几种常用的 webBrowser执行javascript的方法,详见示例截图以及代码 [实例截图] [核心代码] execScript方式: 1 2 3 4 5 6 7 8 9 1 ...

  8. CSS3火焰文字特效制作教程

    原文:CSS3火焰文字特效制作教程 用一句很俗气的话概括这两天的情况就是:“最近很忙”,虽然手头上有不少很酷的HTML5和CSS3资源,但确实没时间将它们的实现过程写成教程分享给大家.今天刚完成了一个 ...

  9. CSS3实现烟花特效 --web前端

    烟花特效,比较简单,直接贴代码了…… <!DOCTYPE html><html lang="en"><head> <meta charse ...

随机推荐

  1. Android:控件布局(表格布局)TableLayout

    TableLayout继承LinearLayout 实例:用表格布局实现计算机布局>>>>>>>>>>>> 有多少个TableR ...

  2. CSS3实现轮播图效果

    CSS3实现轮播图主要是由css:background-position和css3:animation实现.且实现此轮播需要一张四个图横着相连的图片. 注(Internet Explorer 10.F ...

  3. c3p0配置xml

    c3p0-config.xml <c3p0-config> <default-config> <property name="automaticTestTabl ...

  4. xode View 的封装

    1.Xcode自带头文件的路径 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Develo ...

  5. <b>和<strong>标签区别

    简单说, strong是web标准中xhtml的标签,加强语气,起强调作用(默认是采用加粗来实现强调),逻辑标签: b 是html的,bold粗体. web标准主张xhtml不涉及具体的表现形式,“强 ...

  6. C#语法基础和面向对象编程

    1.C#语法基础 http://www.cnblogs.com/tonney/archive/2011/03/16/1986456.html 2.C#与面向对象基础 很棒的资源,简明扼要,介绍的非常清 ...

  7. mysql列属性auto(mysql笔记四)

    常见的的是一个字段不为null存在默认值 没值得时候才去找默认值,可以插入一个null到 可以为null的行里 主键:可以唯一标识某条记录的字段或者字段的集合 主键设置 主键不可为null,声明时自动 ...

  8. cocos run -p android报错 BUILD FAILED ..\ant\build.xml:892

    使用编译指令生成apk文件时,出现这个错误,是因为重复引用了..\YourGame\cocos2d\cocos\platform\android\java\bin\classes.jar文件. 为什么 ...

  9. python二叉树递归算法之后序遍历,前序遍历,中序遍历

    #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2016-11-18 08:53:45 # @Author : why_not_try ...

  10. Node.js学习笔记 02 Implementing flow control

    What is flow control? 和其它语言一样,Node.js 在代码编写时,如何组织代码,如何写出clean code都是不可避免的难点. 同时,由于Node.js的天然特性(异步,事件 ...