以下是 jQuery+CSS3项目模糊效果特效代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!DOCTYPE html>
<html lang="en">
<head>
<title>Item Blur Effect with CSS3 and jQuery</title>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Item Blur Effect with CSS3 and jQuery - Using Box Shadows, Transform and Transitions" />
<meta name="keywords" content="blur, css3, transition, jquery, box shadow, text shadow, articles, scale, transform, animation" />
<meta name="author" content="Codrops" />
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="js/modernizr.custom.34978.js"></script>
</head>
<body>
<div class="container">
<div class="header">
<a href="#/Tutorials/ExperimentsBackgroundClipText/">
<strong>« Previous Demo: </strong>Experiments with background-clip: text
</a>
<span class="right">
<a href="#/codrops/2011/12/14/item-blur-effect-with-css3-and-jquery/">
<strong>Back to the Codrops Article</strong>
</a>
</span>
<div class="clr"></div>
</div>
<header>
<h1>Item Blur Effect <span>with CSS3 & jQuery</span></h1>
<h2>Using Box Shadows, Transform and Transitions</h2>
</header>
<section class="ib-container" id="ib-container">
<article>
<header>
<h3><a target="_blank" href="#/codrops/2011/12/08/25-examples-of-perfect-color-combinations-in-web-design/">25 Examples of Perfect Color Combinations in Web Design</a></h3>
<span>December 8, 2011 by Gisele Muller</span>
</header>
<p>Today we will show you some examples of websites that are using beautiful and inspiring color combinations that match perfectly and create an eye candy...</p>
</article>
<article>
<header>
<h3><a target="_blank" href="#/codrops/2011/12/08/design-it-to-build-it-what-to-consider-when-designing-for-the-web/">Design It to Build It: What to Consider When Designing for the Web</a></h3>
<span>December 8, 2011 by Patrick Cox</span>
</header>
<p>For me, Photoshop is becoming more and more of a prototyping or blue printing tool: it’s basically just a canvas...</p>
</article>
<article>
<header>
<h3><a target="_blank" href="#/codrops/2011/12/07/splash-and-coming-soon-page-effects-with-css3/">Splash and Coming Soon Page Effects with CSS3</a></h3>
<span>December 7, 2011 by Mary Lou </span>
</header>
<p>CSS3 opens up so many crazy possibilities and today we want to show you how to go wild with splash and coming soon page effects using CSS3 animations.</p>
</article>
<article>
<header>
<h3><a target="_blank" href="#/codrops/2011/12/05/lateral-on-scroll-sliding-with-jquery/">Lateral On-Scroll Sliding with jQuery</a></h3>
<span>December 5, 2011 by Mary Lou </span>
</header>
<p>After getting the request, we are going to show you how to create a “slide-in on scroll” effect. You’ve probably seen this cool effect on some websites, like on Nizo or in the portfolio section of brilliantly designed La Moulade. </p>
</article>
<article>
<header>
<h3><a target="_blank" href="#/codrops/2011/12/01/6-questions-you-should-ask-yourself-when-choosing-fonts/">6 Questions You Should Ask Yourself When Choosing Fonts</a></h3>
<span>December 1, 2011 by Patrick Cox </span>
</header>
<p>Typography is truly a science and many designers spend an entire career devoted to the study. But selecting effective fonts for your project doesn't require...</p>
</article>
<article>
<header>
<h3><a target="_blank" href="#/codrops/2011/11/30/inspiring-examples-of-symbol-and-metaphor-use-in-web-design/">Inspiring Examples of Symbol and Metaphor Use in Web Design</a></h3>
<span>November 30, 2011 by Mary Lou</span>
</header>
<p>There are many creative ways of showing what a website is about: the use of images, videos, descriptions and more. Symbolic graphics and metaphorical pictures...</p>
</article>
<article>
<header>
<h3><a target="_blank" href="#/codrops/2011/11/28/typography-effects-with-css3-and-jquery/">Typography Effects with CSS3 and jQuery</a></h3>
<span>November 28, 2011 by Mary Lou</span>
</header>
<p>Today we will create a set of nice typography effects for big headlines using CSS3 and jQuery. There are many things we can do with CSS3 animations and transitions and we’ll...</p>
</article>
<article>
<header>
<h3><a target="_blank" href="#/codrops/2011/11/24/top-10-reasons-to-use-html5-right-now/">Top 10 Reasons to Use HTML5 Right Now</a></h3>
<span>November 24, 2011 by Patrick Cox </span>
</header>
<p>So you're still not using HTML5, huh? I guess you probably have your reasons; it's not fully adopted yet, it doesn't work in IE, you don't like users, you're out of touch or you are just...</p>
</article>
</section>
</div>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var $container = $('#ib-container'),
$articles = $container.children('article'),
timeout;
$articles.on( 'mouseenter', function( event ) {
var $article = $(this);
clearTimeout( timeout );
timeout = setTimeout( function() {
if( $article.hasClass('active') ) return false;
$articles.not( $article.removeClass('blur').addClass('active') )
.removeClass('active')
.addClass('blur');
}, 65 );
});
$container.on( 'mouseleave', function( event ) {
clearTimeout( timeout );
$articles.removeClass('active blur');
});
});
</script>
</body>
</html>
JS代码(modernizr.custom.34978.js):
/* Modernizr 2.0.6 (Custom Build) | MIT & BSD * Build:http://www.modernizr.com/download/#-iepp-cssclasses-load */
;
window.Modernizr=function(a,b,c){
function x(a,b){
return!!~(""+a).indexOf(b)}
function w(a,b){
return typeof a===b}
function v(a,b){
return u(prefixes.join(a+";
")+(b||""))}
function u(a){
k.cssText=a}
var d="2.0.6",e={
}
,f=!0,g=b.documentElement,h=b.head||b.getElementsByTagName("head")[0],i="modernizr",j=b.createElement(i),k=j.style,l,m=Object.prototype.toString,n={
}
,o={
}
,p={
}
,q=[],r,s={
}
.hasOwnProperty,t;
!w(s,c)&&!w(s.call,c)?t=function(a,b){
return s.call(a,b)}
:t=function(a,b){
return b in a&&w(a.constructor.prototype[b],c)}
;
for(var y in n)t(n,y)&&(r=y.toLowerCase(),e[r]=n[y](),q.push((e[r]?"":"no-")+r));
u(""),j=l=null,a.attachEvent&&function(){
var a=b.createElement("div");
a.innerHTML="<elem></elem>";
return a.childNodes.length!==1}
()&&function(a,b){
function s(a){
var b=-1;
while(++b<g)a.createElement(f[b])}
a.iepp=a.iepp||{
}
;
var d=a.iepp,e=d.html5elements||"abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",f=e.split("|"),g=f.length,h=new RegExp("(^|\\s)("+e+")","gi"),i=new RegExp("<(/*)("+e+")","gi"),j=/^\s*[\{
\}
]\s*$/,k=new RegExp("(^|[^\\n]*?\\s)("+e+")([^\\n]*)({
[\\n\\w\\W]*?}
)","gi"),l=b.createDocumentFragment(),m=b.documentElement,n=m.firstChild,o=b.createElement("body"),p=b.createElement("style"),q=/print|all/,r;
d.getCSS=function(a,b){
if(a+""===c)return"";
var e=-1,f=a.length,g,h=[];
while(++e<f){
g=a[e];
if(g.disabled)continue;
b=g.media||b,q.test(b)&&h.push(d.getCSS(g.imports,b),g.cssText),b="all"}
return h.join("")}
,d.parseCSS=function(a){
var b=[],c;
while((c=k.exec(a))!=null)b.push(((j.exec(c[1])?"\n":c[1])+c[2]+c[3]).replace(h,"$1.iepp_$2")+c[4]);
return b.join("\n")}
,d.writeHTML=function(){
var a=-1;
r=r||b.body;
while(++a<g){
var c=b.getElementsByTagName(f[a]),d=c.length,e=-1;
while(++e<d)c[e].className.indexOf("iepp_")<0&&(c[e].className+=" iepp_"+f[a])}
l.appendChild(r),m.appendChild(o),o.className=r.className,o.id=r.id,o.innerHTML=r.innerHTML.replace(i,"<$1font")}
,d._beforePrint=function(){
p.styleSheet.cssText=d.parseCSS(d.getCSS(b.styleSheets,"all")),d.writeHTML()}
,d.restoreHTML=function(){
o.innerHTML="",m.removeChild(o),m.appendChild(r)}
,d._afterPrint=function(){
d.restoreHTML(),p.styleSheet.cssText=""}
,s(b),s(l);
d.disablePP||(n.insertBefore(p,n.firstChild),p.media="print",p.className="iepp-printshim",a.attachEvent("onbeforeprint",d._beforePrint),a.attachEvent("onafterprint",d._afterPrint))}
(a,b),e._version=d,g.className=g.className.replace(/\bno-js\b/,"")+(f?" js "+q.join(" "):"");
return e}
(this,this.document),function(a,b,c){
function k(a){
return!a||a=="loaded"||a=="complete"}
function j(){
var a=1,b=-1;
while(p.length- ++b)if(p[b].s&&!(a=p[b].r))break;
a&&g()}
function i(a){
var c=b.createElement("script"),d;
c.src=a.s,c.onreadystatechange=c.onload=function(){
!d&&k(c.readyState)&&(d=1,j(),c.onload=c.onreadystatechange=null)}
,m(function(){
d||(d=1,j())}
,H.errorTimeout),a.e?c.onload():n.parentNode.insertBefore(c,n)}
function h(a){
var c=b.createElement("link"),d;
c.href=a.s,c.rel="stylesheet",c.type="text/css";
if(!a.e&&(w||r)){
var e=function(a){
m(function(){
if(!d)try{
a.sheet.cssRules.length?(d=1,j()):e(a)}
catch(b){
b.code==1e3||b.message=="security"||b.message=="denied"?(d=1,m(function(){
j()}
,0)):e(a)}
}
,0)}
;
e(c)}
else c.onload=function(){
d||(d=1,m(function(){
j()}
,0))}
,a.e&&c.onload();
m(function(){
d||(d=1,j())}
,H.errorTimeout),!a.e&&n.parentNode.insertBefore(c,n)}
function g(){
var a=p.shift();
q=1,a?a.t?m(function(){
a.t=="c"?h(a):i(a)}
,0):(a(),j()):q=0}
function f(a,c,d,e,f,h){
function i(){
!o&&k(l.readyState)&&(r.r=o=1,!q&&j(),l.onload=l.onreadystatechange=null,m(function(){
u.removeChild(l)}
,0))}
var l=b.createElement(a),o=0,r={
t:d,s:c,e:h}
;
l.src=l.data=c,!s&&(l.style.display="none"),l.width=l.height="0",a!="object"&&(l.type=d),l.onload=l.onreadystatechange=i,a=="img"?l.onerror=i:a=="script"&&(l.onerror=function(){
r.e=r.r=1,g()}
),p.splice(e,0,r),u.insertBefore(l,s?null:n),m(function(){
o||(u.removeChild(l),r.r=r.e=o=1,j())}
,H.errorTimeout)}
function e(a,b,c){
var d=b=="c"?z:y;
q=0,b=b||"j",C(a)?f(d,a,b,this.i++,l,c):(p.splice(this.i++,0,a),p.length==1&&g());
return this}
function d(){
var a=H;
a.loader={
load:e,i:0}
;
return a}
var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={
}
.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=r&&!s,u=s?l:n.parentNode,v=a.opera&&o.call(a.opera)=="[object Opera]",w="webkitAppearance"in l.style,x=w&&"async"in b.createElement("script"),y=r?"object":v||x?"img":"script",z=w?"img":y,A=Array.isArray||function(a){
return o.call(a)=="[object Array]"}
,B=function(a){
return Object(a)===a}
,C=function(a){
return typeof a=="string"}
,D=function(a){
return o.call(a)=="[object Function]"}
,E=[],F={
}
,G,H;
H=function(a){
function f(a){
var b=a.split("!"),c=E.length,d=b.pop(),e=b.length,f={
url:d,origUrl:d,prefixes:b}
,g,h;
for(h=0;
h<e;
h++)g=F[b[h]],g&&(f=g(f));
for(h=0;
h<c;
h++)f=E[h](f);
return f}
function e(a,b,e,g,h){
var i=f(a),j=i.autoCallback;
if(!i.bypass){
b&&(b=D(b)?b:b[a]||b[g]||b[a.split("/").pop().split("?")[0]]);
if(i.instead)return i.instead(a,b,e,g,h);
e.load(i.url,i.forceCSS||!i.forceJS&&/css$/.test(i.url)?"c":c,i.noexec),(D(b)||D(j))&&e.load(function(){
d(),b&&b(i.origUrl,h,g),j&&j(i.origUrl,h,g)}
)}
}
function b(a,b){
function c(a){
if(C(a))e(a,h,b,0,d);
else if(B(a))for(i in a)a.hasOwnProperty(i)&&e(a[i],h,b,i,d)}
var d=!!a.test,f=d?a.yep:a.nope,g=a.load||a.both,h=a.callback,i;
c(f),c(g),a.complete&&b.load(a.complete)}
var g,h,i=this.yepnope.loader;
if(C(a))e(a,0,i,0);
else if(A(a))for(g=0;
g<a.length;
g++)h=a[g],C(h)?e(h,0,i,0):A(h)?H(h):B(h)&&b(h,i);
else B(a)&&b(a,i)}
,H.addPrefix=function(a,b){
F[a]=b}
,H.addFilter=function(a){
E.push(a)}
,H.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",G=function(){
b.removeEventListener("DOMContentLoaded",G,0),b.readyState="complete"}
,0)),a.yepnope=d()}
(this,this.document),Modernizr.load=function(){
yepnope.apply(window,[].slice.call(arguments,0))}
;
CSS代码(demo.css):
/* CSS reset */
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}
html,body{margin:0;padding:0;}
table{border-collapse:collapse;border-spacing:0;}
fieldset,img{border:0;}
input{border:1px solid #b0b0b0;padding:3px 5px 4px;color:#979797;width:190px;}
address,caption,cite,code,dfn,th,var{font-style:normal;font-weight:normal;}
ol,ul{list-style:none;}
caption,th{text-align:left;}
h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}
q:before,q:after{content:'';}
abbr,acronym{border:0;}
/* Fonts */
/* Generated by Font Squirrel (http://www.fontsquirrel.com) */
@font-face{font-family:'BebasNeueRegular';src:url('fonts/BebasNeue-webfont.eot');src:url('fonts/BebasNeue-webfont.eot?#iefix') format('embedded-opentype'),url('fonts/BebasNeue-webfont.woff') format('woff'),url('fonts/BebasNeue-webfont.ttf') format('truetype'),url('fonts/BebasNeue-webfont.svg#BebasNeueRegular') format('svg');font-weight:normal;font-style:normal;}
/* General Demo Style */
body{font-family:Constantia,Palatino,"Palatino Linotype","Palatino LT STD",Georgia,serif;background:#ddd url(../images/noisy_blue.jpg) repeat top left;font-weight:400;font-size:15px;color:#333;}
a{color:#333;text-decoration:none;}
.container{width:100%;position:relative;text-align:center;}
.clr{clear:both;}
.container > header{padding:30px 30px 10px 30px;margin:0px 20px 10px 20px;position:relative;display:block;}
.container > header:after{content:'';height:1px;width:100%;position:absolute;bottom:0px;left:0px;background:rgba(0,0,0,0.1);box-shadow:0px 1px 0px 0px rgba(255,255,255,0.7);}
h1{font-family:'BebasNeueRegular','Arial Narrow',Arial,sans-serif;text-transform:uppercase;font-size:50px;line-height:50px;position:relative;font-weight:400;color:#111;text-shadow:0px 0px 1px rgba(0,0,0,0.7);padding:0px 0px 5px 0px;margin:0px 20px;text-align:center;}
h1 span{color:#ffd252;text-shadow:0px 1px 1px rgba(0,0,0,0.3);}
h2{font-size:16px;font-style:italic;padding:0px 0px 15px 0px;}
/* Header Style */
.header{font-family:'Arial Narrow',Arial,sans-serif;line-height:24px;font-size:11px;background:#000;opacity:0.9;text-transform:uppercase;z-index:9999;position:relative;-moz-box-shadow:1px 0px 2px #000;-webkit-box-shadow:1px 0px 2px #000;box-shadow:1px 0px 2px #000;}
.header a{padding:0px 10px;letter-spacing:1px;color:#ddd;display:block;float:left;}
.header a:hover{color:#fff;}
.header span.right{float:right;}
.header span.right a{float:none;display:inline;}
p.demos{font-family:'BebasNeueRegular','Arial Narrow',Arial,sans-serif;text-align:center;display:block;line-height:30px;padding:20px 0px;}
p.demos a{display:inline-block;width:60px;height:60px;background:#222;margin:0px 4px;color:#fff;line-height:60px;-webkit-border-radius:30px;-moz-border-radius:30px;border-radius:50%;font-size:16px;-webkit-transition:all 0.2s linear;-moz-transition:all 0.2s linear;-o-transition:all 0.2s linear;-ms-transition:all 0.2s linear;transition:all 0.2s linear;-webkit-box-shadow:0px 0px 0px 10px rgba(0,0,0,0.2);-moz-box-shadow:0px 0px 0px 10px rgba(0,0,0,0.2);box-shadow:0px 0px 0px 10px rgba(0,0,0,0.2);}
p.demos a:hover{opacity:0.7;}
p.demos a.current-demo,p.demos a.current-demo:hover{background:#ffd252;}
CSS代码(style.css):
.ib-container{position:relative;width:800px;margin:30px auto;display:block;}
.ib-container:before,.ib-container:after{content:"";display:table;}
.ib-container:after{clear:both;}
.ib-container article{display:block;width:140px;height:220px;background:#fff;cursor:pointer;float:left;border:10px solid #fff;text-align:left;text-transform:none;margin:15px;z-index:1;-webkit-backface-visibility:hidden;box-shadow:0px 0px 0px 10px rgba(255,255,255,1),1px 1px 3px 10px rgba(0,0,0,0.2);-webkit-transition:opacity 0.4s linear,-webkit-transform 0.4s ease-in-out,box-shadow 0.4s ease-in-out;-moz-transition:opacity 0.4s linear,-moz-transform 0.4s ease-in-out,box-shadow 0.4s ease-in-out;-o-transition:opacity 0.4s linear,-o-transform 0.4s ease-in-out,box-shadow 0.4s ease-in-out;-ms-transition:opacity 0.4s linear,-ms-transform 0.4s ease-in-out,box-shadow 0.4s ease-in-out;transition:opacity 0.4s linear,transform 0.4s ease-in-out,box-shadow 0.4s ease-in-out;}
.ib-container h3 a{font-size:16px;font-weight:400;color:#000;color:rgba(0,0,0,1);text-shadow:0px 0px 0px rgba(0,0,0,1);opacity:0.8;}
.ib-container article header span{font-size:10px;font-family:"Big Caslon","Book Antiqua","Palatino Linotype",Georgia,serif;padding:10px 0;display:block;color:#FFD252;color:rgba(255,210,82,1);text-shadow:0px 0px 0px rgba(255,210,82,1);text-transform:uppercase;opacity:0.8;}
.ib-container article p{font-family:Verdana,sans-serif;font-size:10px;line-height:13px;color:#333;color:rgba(51,51,51,1);text-shadow:0px 0px 0px rgba(51,51,51,1);opacity:0.8;}
.ib-container h3 a,.ib-container article header span,.ib-container article p{-webkit-transition:opacity 0.2s linear,text-shadow 0.5s ease-in-out,color 0.5s ease-in-out;-moz-transition:opacity 0.2s linear,text-shadow 0.5s ease-in-out,color 0.5s ease-in-out;-o-transition:opacity 0.2s linear,text-shadow 0.5s ease-in-out,color 0.5s ease-in-out;-ms-transition:opacity 0.2s linear,text-shadow 0.5s ease-in-out,color 0.5s ease-in-out;transition:opacity 0.2s linear,text-shadow 0.5s ease-in-out,color 0.5s ease-in-out;}
/* Hover Style for all the items:blur,scale down*/
.ib-container article.blur{box-shadow:0px 0px 20px 10px rgba(255,255,255,1);-webkit-transform:scale(0.9);-moz-transform:scale(0.9);-o-transform:scale(0.9);-ms-transform:scale(0.9);transform:scale(0.9);opacity:0.7;}
.ib-container article.blur h3 a{text-shadow:0px 0px 10px rgba(0,0,0,0.9);color:rgba(0,0,0,0);opacity:0.5;}
.ib-container article.blur header span{text-shadow:0px 0px 10px rgba(255,210,82,0.9);color:rgba(255,210,82,0);opacity:0.5;}
.ib-container article.blur p{text-shadow:0px 0px 10px rgba(51,51,51,0.9);color:rgba(51,51,51,0);opacity:0.5;}
/* Hover Style for single item:scale up */
.ib-container article.active{-webkit-transform:scale(1.05);-moz-transform:scale(1.05);-o-transform:scale(1.05);-ms-transform:scale(1.05);transform:scale(1.05);box-shadow:0px 0px 0px 10px rgba(255,255,255,1),1px 11px 15px 10px rgba(0,0,0,0.4);z-index:100;opacity:1;}
.ib-container article.active h3 a,.ib-container article.active header span,.ib-container article.active p{opacity;1;}