知识大全 固定背景实现的背景滚动特效示例

Posted 背景

篇首语:吃过的馍馍不香,嚼过的甘蔗不甜。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 固定背景实现的背景滚动特效示例相关的知识,希望对你有一定的参考价值。

  分享一个来自corpse的固定背景滚动特效 使用background attachment: fixed和导航菜单 页面会非常平滑的滚动  

  HTML

代码如下: <div id="cbp fbscroller" > <nav> <a href="#fbsection " >Section </a> <a href="#fbsection ">Section </a> <a href="#fbsection ">Section </a> <a href="#fbsection ">Section </a> <a href="#fbsection ">Section </a> </nav> <section id="fbsection "></section> <section id="fbsection "></section> <section id="fbsection "></section> <section id="fbsection "></section> <section id="fbsection "></section> </div>

   CSS

 代码如下: /* Set all parents to full height */ body container cbp fbscroller cbp fbscroller section height: %; /* The nav is fixed on the right side and we center it by translating it % (we don t know it s height so we can t use the negative margin trick) */ cbp fbscroller > nav position: fixed; z index: ; right: px; top: %; webkit transform: translateY( %); moz transform: translateY( %); ms transform: translateY( %); transform: translateY( %); cbp fbscroller > nav a display: block; position: relative; color: transparent; height: px; cbp fbscroller > nav a:after content: ; position: absolute; width: px; height: px; border radius: %; border: px solid #fff; cbp fbscroller > nav a:hover:after background: rgba( ); cbp fbscroller > nav a cbp fbcurrent:after background: #fff; /* background attachment does the trick */ cbp fbscroller section position: relative; background position: top center; background repeat: no repeat; background size: cover; background attachment: fixed; #fbsection background image: url( /images/ jpg); #fbsection background image: url( /images/ jpg); #fbsection background image: url( /images/ jpg); #fbsection background image: url( /images/ jpg); #fbsection background image: url( /images/ jpg);  代码如下: /** * cbpFixedScrollLayout js v * * * Licensed under the MIT license * * * Copyright Codrops * */ var cbpFixedScrollLayout = (function() // cache and initialize some values var config = // the cbp fbscroller′s sections $sections : $( #cbp fbscroller > section ) // the navigation links $navlinks : $( #cbp fbscroller > nav:first > a ) // index of current link / section currentLink : // the body element $body : $( body ) // the body animation speed animspeed : // the body animation easing (jquery easing) animeasing : easeInOutExpo ; function init() // click on a navigation link: the body is scrolled to the position of the respective section config $navlinks on( click function() scrollAnim( config $sections eq( $( this ) index() ) offset() top ); return false; ); // waypoints defined: // First one when we scroll down: the current navigation link gets updated // A `new section′ is reached when it occupies more than % of the viewport // Second one when we scroll up: the current navigation link gets updated // A `new section′ is reached when it occupies more than % of the viewport config $sections waypoint( function( direction ) if( direction === down ) changeNav( $( this ) ); offset: % ) waypoint( function( direction ) if( direction === up ) changeNav( $( this ) ); offset: % ); // on window resize: the body is scrolled to the position of the current section $( window ) on( debouncedresize function() scrollAnim( config $sections eq( config currentLink ) offset() top ); ); // update the current navigation link function changeNav( $section ) config $navlinks eq( config currentLink ) removeClass( cbp fbcurrent ); config currentLink = $section index( section ); config $navlinks eq( config currentLink ) addClass( cbp fbcurrent ); // function to scroll / animate the body function scrollAnim( top ) config $body stop() animate( scrollTop : top config animspeed config animeasing ); return init : init ; )();  cha138/Article/program/Java/JSP/201311/20507

相关参考

知识大全 网页标准的随滚动条滚动的广告特效

cha138/Article/program/Java/Javascript/201311/25350

知识大全 网页前端优化之滚动延时加载图片示例

做web开发的朋友都应该掌握前端优化这个技巧其中一个就是滚动延时加载这个技巧应用在了很多地方比如新浪微博网页版以下就为大家详细介绍需要的朋友可以参考下   为什么要延时加载呢?页面加载的时候

知识大全 用JavaScript实现上下文字滚动特效

用JavaScript实现上下文字滚动特效  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  文字左

知识大全 JS仿QQ商城点击左右滚动jquery焦点图特效

JS仿QQ商城点击左右滚动jquery焦点图特效  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  

知识大全 jquery特效 幻灯片效果示例代码

jquery特效中的幻灯片想必大家已不陌生吧下面为大家分享个比较不错的幻灯片效果附有源码感兴趣的朋友可以学习下哈   jquery特效幻灯片效果效果图如下 复制代码代码如下:lis

知识大全 纯JavaScript实现HTML5 Canvas六种特效滤镜示例

纯JavaScript实现HTML5Canvas六种特效滤镜示例  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起

知识大全 凡客诚品带滚动条图片展示特效

  如果现在比较专业的商城估计凡客算是其中之一了像当当及京东都变得啥都有了看到凡客那么多照片我就在想一件事究竟得请多少人去拍照片整理照片还要有多少模特不愧是大公司今天我们进入凡客的丝袜频道相信许多男生

知识大全 这种特效照片是用什么软件做出来的

这种特效照片是用什么软件做出来的选好人物和背景素材,PhotoShop中修改素材和人形差不多然后滤色,再适当调整到满意效果。这种照片是用什么软件做出来的?这个软件叫做脸萌手机版美图秀秀图片虚化之后在插

如何抓拍跳跃的瞬间

要想抓拍一个跳跃的瞬间,首先要选好跳跃主体和画面背景。以天空作为背景会增强画面的整体效果。选定好摄影地点后,把相机固定在三脚架上,并且降低三脚架的高度,并选择构图。为了拍摄人物跳跃的空中姿态,摄影者要

知识大全 利用jquery的滚动条滚动固定div

cha138/Article/program/Java/JSP/201311/20304