给图层加阴影jQuery代码

版权:原创 更新时间:1年以上
[该文章底部包含文件资源,可根据自己情况,决定是否下载资源使用,时间>金钱,如有需要,立即查看资源]

以下是 给图层加阴影jQuery代码 的示例演示效果:

当前平台(PC电脑)
  • 平台:

部分效果截图:

给图层加阴影jQuery代码

HTML代码(index.html):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>Overlay-like Effect with jQuery</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="description" content="Overlay-like Effect with jQuery" />
        <meta name="keywords" content="overlay, jquery, effect, fade out, change color, animate"/>
		<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"/>
        <link rel="stylesheet" type="text/css" href="css/style.css" />
    </head>
    <body>
		<div class="header">
			<a class="left" href="#"><<< Fullscreen Gallery with Thumbnail Flip</a>
			<a class="back" href="#">back to the Codrops tutorial >>></a>
		</div>
		<div id="container" class="container">
			<ul id="menu" class="menu">
				<li><a href="#"><img src="images/1.png" alt="1"/></a></li>
				<li><a href="#"><img src="images/2.png" alt="2"/></a></li>
				<li><a href="#"><img src="images/3.png" alt="3"/></a></li>
				<li><a href="#"><img src="images/4.png" alt="4"/></a></li>
				<li><a href="#" id="effect-n"><img src="images/5.png" alt="5"/></a></li>
			</ul>
			<div class="content">
				<h1>Overlay-like Effect</h1>
				<h2>Custom effects with jQuery</h2>

				<p>A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine.</p>

				<p>I am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. I should be incapable of drawing a single stroke at the present moment; and yet I feel that I never was a greater artist than now.</p>
				
				<h3 class="effect-n">Vapour around me</h3>
				<p class="effect-n">When, while the lovely valley teems with vapour around me, and the meridian sun strikes the upper surface of the impenetrable foliage of my trees, and but a few stray gleams steal into the inner sanctuary.</p>
				
				<p class="effect-n">O my friend -- but it is too much for my strength -- I sink under the weight of the splendour of these visions!</p>
				<h3>I am so happy, my dear friend</h3>
				<p>A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine.</p>
				
				
				<p>I am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents.</p>

				<p>I should be incapable of drawing a single stroke at the present moment; and yet I feel that I never was a greater artist than now.</p>

				<p>When, while the lovely valley teems with vapour around me, and the meridian sun strikes the upper surface of the impenetrable foliage of my trees, and but a few stray gleams steal into the inner sanctuary, I throw myself down among the tall grass by the trickling stream; and, as I lie close to the earth, a thousand unknown plants are noticed by me: when I hear the buzz of the little world among the stalks, and grow familiar with the countless indescribable forms of the insects and flies, then I feel the presence of the Almighty, who formed us in his own image, and the breath of that universal love which bears and sustains us, as it floats around us in an eternity of bliss; and then, my friend, when darkness overspreads my eyes, and heaven and earth seem to dwell in my soul and absorb its power, like the form of a beloved mistress, then I often think with longing, Oh, would I could describe these conceptions, could impress upon paper all that is living so full and warm within me, that it might be the mirror of my soul, as my soul is the mirror of the infinite God!</p>
				
				<h3>I sink under the weight</h3>
				<p>O my friend -- but it is too much for my strength -- I sink under the weight of the splendour of these visions!</p>

				<p>A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart.</p>

				<p>I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine.</p>

				<p>I am so happy, my dear friend.</p>
			</div>

			<div class="footer">
				Tutorials and Demos by Codrops 
				<a href="http://13141618.taobao.com/">Sc.chinaz.com</a>|
				 
			</div>
		</div>
		<!-- The JavaScript -->
		<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
		<script type="text/javascript" src="jquery-ui.min.js"></script>
        <script type="text/javascript">
			$(function() {
			/*
			the menu list element,
			the container and content divs
			*/
			var $menu			= $('#menu'),
				$container		= $('#container'),
				$content		= $container.find('.content');
			
			/*
			lets add the classes effect, e-fade, and e-color to some elements.
			e-fade : this will decrease the opacity of the element
			e-color: this will change the color of the element
			*/		
			$content
			.find('p')
			.addClass('effect e-fade')
			.end()
			.find('h1, h2, h3')
			.addClass('effect e-fade e-color');
				
			/*
			elems is all the elements with class effect.
			overlayEffect is our function / module that will take care of the animations
			*/	
			var $elems			= $(document).find('.effect'),
				OverlayEffect 	= (function(){
						//speed for animations
					var speed				= 1000,
						//the event that triggers the effect
						eventOff			= 'mouseenter',
						//the event that stops the effect
						eventOn				= 'mouseleave',
						//this is the color that the elements will have after eventOff
						colorOff			= '#AAAAAA',
						//saves the original color of each e-color element,
						//and calls the methos to initialize the events
						init				= function() {
							$elems.each(function(){
								var $el		= $(this);
								if($el.hasClass('e-color'))	
									$el.data('original-color',$el.css('color'));
							});
							initEventsHandler();
						},
						//initializes the events eventOff / eventOn
						initEventsHandler 	= function() {
							$menu
							.delegate('a',eventOff,function(e){
								//relation is the id of the element, 
								//and the class of related elements
								var relation	= $(this).attr('id');
								animateElems('off',relation);
								return false;
							})
							.delegate('a',eventOn,function(e){
								var relation	= $(this).attr('id');
								animateElems('on',relation);
								return false;
							});	
						},
						//animates the color and / or opacity
						animateElems		= function(dir,relation) {
							var $e	= $elems;
							
							switch(dir){
								case 'on'	:
									//if there are elements on the page with class = relation
									//then these elements will be excluded for the animation
									if(relation)
										$e	= $elems.not('.'+relation);
									
									$e.each(function(){
										var $el		= $(this),
											color	= $el.data('original-color'),
											param	= {};
										
										if($el.hasClass('e-color'))
											param.color		= color;
										if($el.hasClass('e-fade'))
											param.opacity	= 1;

										$el.stop().animate(param,speed);	
									});
									
									break;
								case 'off'	:
									if(relation)
										$e	= $elems.not('.'+relation);
									
									$e.each(function(){
										var $el		= $(this),
											param	= {};
										
										if($el.hasClass('e-color'))
											param.color		= colorOff;
										if($el.hasClass('e-fade'))
											param.opacity	= 0.1;

										$el.stop().animate(param,speed);	
									});
									
									break;
							}
						};
						
					return {
						init				: init
					};
				})();
				
			/*
			call the init method of OverlayEffect
			*/
			OverlayEffect.init();
			});
        </script>
    </body>
</html>

CSS代码(style.css):

*{margin:0;padding:0;}
html,body{margin:0;padding:0;height:100%;}
body{font-family:Arial,Helvetica,sans-serif;font-size:14px;background:#333;color:#fff;text-shadow:1px 1px 1px #000;}
.header{text-align:center;width:100%;height:35px;clear:both;background:#000 url(../images/stripe.gif) repeat top left;border-bottom:7px solid #222;font-size:11px;line-height:35px;font-style:italic;}
.header a{color:#aaa;text-shadow:1px 1px 1px #000;padding-right:20px;}
.header a:hover{color:#fff;}
.container{position:relative;/* needed for footer positioning*/
margin:0 auto;/* center,not in IE5 */
width:100%;height:auto !important;/* real browsers */
height:100%;/* IE6:treaded as min-height*/
min-height:100%;/* real browsers */
}
.left{float:left;margin-left:10px;}
.back{position:absolute;right:10px;top:0px;}
h1,h3{font-size:56px;color:#5eb1e0;font-weight:normal;}
h3{font-size:20px;padding:10px;}
h2{font-size:26px;font-weight:normal;color:#aaa;padding:10px;}
a{color:#777;text-decoration:none;}
p{padding:10px;color:#ccc;text-shadow:none;font-size:12px;letter-spacing:1px;text-align:justify;}
.content{padding:40px 40px 80px 40px;width:500px;background:#222;margin-left:80px;position:relative;}
.footer{position:absolute;width:100%;height:50px;line-height:50px;bottom:0;/* stick to bottom */
background:#f0f0f0;border-top:7px solid #222;text-align:center;text-shadow:1px 1px 1px #000;color:#fff;background:#000 url(../images/stripe.gif) repeat top left;}
.footer a{color:#aaa;padding:0px 10px;text-shadow:1px 1px 1px #000;}
.footer a:hover{color:#fff;text-shadow:0px 0px 1px #fff;}
ul.menu{list-style:none;position:fixed;height:270px;width:54px;left:660px;top:42px;}
ul.menu li{display:block;}
ul.menu li a{background:#555;display:block;padding:10px;width:30px;height:30px;line-height:30px;outline:none;border:2px solid #333;text-align:center;}
ul.menu li a:hover{background:#fff;}
ul.menu li a img{border:none;}
附件:下载该文件资源,减少时间成本(增值服务)
留言
该资源可下载
File Source
.rar
84.72 KB
最新结算
jquery虚拟键盘中文打字效果js代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
jquery虚拟键盘中文打字效果js代码
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
HTML5实现CSS滤镜图片切换特效代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
jQuery头像裁剪插件cropbox js代码
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
jQuery头像裁剪插件cropbox js代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
jQuery+css3实现信封效果
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
我们力求给您提供有用的文章,再此基础上,会附加营收资源,不做任何广告,让平台可以更好发展 若您发现您的权利被侵害,或使用了您的版权,请发邮件联系 sunlifel@foxmail.com ggbig觉得 : 不提供源码的文章不是好文章
合作伙伴
联系我们
  • QQ:21499807
  • 邮箱:sunlifel@foxmail.com
  • QQ扫一扫加QQ
    QQ扫一扫
Copyright 2023-2024 ggbig.com·皖ICP备2023004211号-1
打赏文章