网站怎么做图片动态图片,比较好写的电子商务论文题目,网站建设需求统计表,网站seo外包技术资源1.什么是headroom.js#xff1f; headroom是用纯Javascript写的插件#xff0c;用来隐藏和展示页面元素#xff0c;从而为页面留下更多空间。比如使用headroom能使导航栏当页面下滚时消失#xff0c;当页面上滚时候又出现。#xff08;查看效果#xff09; 2.工作原理 通… 1.什么是headroom.js headroom是用纯Javascript写的插件用来隐藏和展示页面元素从而为页面留下更多空间。比如使用headroom能使导航栏当页面下滚时消失当页面上滚时候又出现。查看效果 2.工作原理 通过感应目标元素不同的3种状态原始下滚上滚为目标元素更改相应的class通过相应的class的css样式的变化得到所要的效果。 3.如何使用 以下的例子是基于bootstrap框架和jquery插件的在bootstrap框架下可以快速写出导航栏navbar然后以jquery插件方式对导航栏navbar调用headroom()。 首先需要引用headroom.js和jQuery.headroom.js。将以下的代码加入到你的代码中。headroom.js作用感应元素不同的状态为之更改相应的class。jQuery.headroom.js作用提供jquery插件方式和Data-API方式调用headrooom()。 script typetext/javascript srchttps://rawgithub.com/WickyNilliams/headroom.js/master/dist/headroom.js/scriptscript typetext/javascript srchttps://rawgithub.com/WickyNilliams/headroom.js/master/src/jQuery.headroom.js/script 因为headroom()函数传入的参数option对象的默认值如下。 {// 在元素没有固定之前垂直方向的偏移量以px为单位offset : 0,// scroll tolerance in px before state changestolerance : 0,// 对于每个状态都可以自定义css classes classes : {// 当元素初始化后所设置的classinitial : headroom,// 向上滚动时设置的classpinned : headroom--pinned,// 向下滚动时所设置的classunpinned : headroom--unpinned}
} 由此可知原始的状态对应的class是headroom下滚时的class是headroom--pinned上滚时的class是headroom--unpinned。所以我们要添加下面的样式通过css的trasition属性达到变换效果。 style typetext/css.headroom {position: fixed;top: 0;left: 0;right: 0;transition: all .2s ease-in-out;}.headroom--unpinned {top: -100px;}.headroom--pinned {top: 0;}/style 之后添加下面的js代码使用jquery插件的方式调用。.navbar-fixed-top只是用来获取导航栏navbar也可以用其他选择器来获取navbar目标元素 script typetext/javascript $(.navbar-fixed-top).headroom(); /script 做完了上述步骤理论上你就可以看到headroom的效果了如果没有成功可能是以下的原因 1、js的引用顺序错误因为一些js要用到其他js才能运行的所以必须放在其他的js之后。例如 script typetext/javascript$(.navbar-fixed-top).headroom();
/script 必须放在headroom.js和jQuery.headroom.js之后而headroom.js和jQuery.headroom.js必须放在jQuery.js之后。 2、将$(.navbar-fixed-top).headroom(); 放在主体html代码之前如放在head/head中因为在主体html代码之前navbar元素还没加载就调用 了headroom()所以无效。应该用以下代码替换之表示等文档加载完毕再调用。 script typetext/javascript$(doucument).ready(fuction(){$(.navbar-fixed-top).headroom(); }); /script 上述的效果只是通过css自带的trasition属性来实现效果比较单调。不过可以结合animate.css实现更多的漂亮的消失和出现的效果。查看效果 animate.css使用纯css为各种元素实现不同的动画效果每一种class对应一种动画效果所以将animate.css引入代码后headroom()可以直接使用已经写好的class。animate.css下载 我基于bootstrap和jquery写得例子。 1 !DOCTYPE html2 html3 head4 titleBootstrap 101 Template/title5 meta nameviewport contentwidthdevice-width, initial-scale1.06 !-- Bootstrap --7 link relstylesheet hrefhttp://cdn.bootcss.com/twitter-bootstrap/3.0.3/css/bootstrap.min.css8 9 link relstylesheet hrefI:/webpage/animate/animate.css10 11 !-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --12 !-- WARNING: Respond.js doesnt work if you view the page via file:// --13 !--[if lt IE 9]14 script srchttp://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.min.js/script15 script srchttp://cdn.bootcss.com/respond.js/1.3.0/respond.min.js/script16 ![endif]--17 style typetext/css18 .headroom {position: fixed;top: 0;left: 0;right: 0;transition: all .2s ease-in-out;}19 .headroom--unpinned {top: -100px;}20 .headroom--pinned {top: 0;}21 /style22 23 style typetext/css24 .scrollspy-example {25 height: 1200px;26 overflow: auto;27 position: relative;28 }29 /style30 31 32 /head33 body34 35 !-- 页眉大屏显示 --36 div classjumbotron37 div classcontainer38 h1Hello, world!/h139 pThis is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique./p40 pa classbtn btn-primary btn-lg rolebuttonLearn more »/a/p41 /div42 /div43 44 div classcontainer45 46 !-- 导航栏 --47 nav classnavbar navbar-inverse navbar-fixed-top rolenavigation idexample48 div classnavbar-header49 a classnavbar-brand href#w3school/a50 /div51 52 div classcollapse navbar-collapse idtem53 ul classnav navbar-nav54 li classactivea href#phpPHP/a/li55 lia href#jsJS/a/li56 li classdropdown57 a href# classdropdown-toggle data-toggledropdowndatabaseb classcaret/b/a58 59 ul classdropdown-menu60 lia href#mysqlMySQL/a/li61 lia href#pgsqlPostgreSQL/a/li62 lia href#mgdbMogoDB/a/li63 /ul64 /li65 /ul66 /div67 /nav68 69 !-- 主体内容--70 div data-spyscroll data-target#example data-offset0 classscrollspy-example71 h4 idphpPHP/h472 pPHP, an acronym for Hypertext Preprocessor, is a widely-used open source general-purpose scripting language. It is an HTML embedded scripting language and is especially suited for web development. The basic syntax of PHP is similar to C, Java, and Perl, and is easy to learn. PHP is used for creating interactive and dynamic web pages quickly, but you can do much more with PHP.73 /p74 h4 idjsJS/h475 p76 JavaScript is a cross-platform, object-oriented scripting language developed by Netscape. JavaScript was created by Netscape programmer Brendan Eich. It was first released under the name of LiveScript as part of Netscape Navigator 2.0 in September 1995. It was renamed JavaScript on December 4, 1995. As JavaScript works on the client side, It is mostly used for client-side web development.77 /p78 h4 idmysqlMySQL/h479 p80 MySQL tutorial of w3cschool is a comprhensive tutorial to learn MySQL. We have hundreds of examples covered, often with PHP code. This helps you to learn how to create PHP-MySQL based web applications.81 /p82 h4 idpgsqlPostgreSQL/h483 p84 In 1986 the Defense Advanced Research Projects Agency (DARPA), the Army Research Office (ARO), the National Science Foundation (NSF), and ESL, Inc sponsored Berkeley POSTGRES Project which was led by Michael Stonebrakessr. In 1987 the first demo version of the project is released. In June 1989, Version 1 was released to some external users. Version 2 and 3 were released in 1990 and 1991. Version 3 had support for multiple storage managers, an query executor was improved, rule system was rewritten. After that, POSTGRES has been started to be implemented in various research and development projects. For example, in late 1992, POSTGRES became the primary data manager for the Sequoia 2000 scientific computing project4. User community around the project also has been started increasing; by 1993, it was doubled.85 /p86 h4 idmgdbMongoDB/h487 p88 The term NoSQL was coined by Carlo Strozzi in the year 1998. He used this term to name his Open Source, Light Weight, DataBase which did not have an SQL interface.In the early 2009, when last.fm wanted to organize an event on open-source distributed databases, Eric Evans, a Rackspace employee, reused the term to refer databases which are non-relational, distributed, and does not conform to atomicity, consistency, isolation, durability - four obvious features of traditional relational database systems.89 /p90 p91 After reading the largest third party online MySQL tutorial by w3cschool, you will be able to install, manage and develop PHP-MySQL web applications by your own. We have a comprehensive, SQL TUTORIAL, which will help you to understand how to prepare queries to fetch data against various conditions.92 /p93 94 /div95 /div96 97 98 !-- jQuery (necessary for Bootstraps JavaScript plugins) --99 script srchttp://cdn.bootcss.com/jquery/1.10.2/jquery.min.js/script
100 !-- Include all compiled plugins (below), or include individual files as needed --
101 script srchttp://cdn.bootcss.com/twitter-bootstrap/3.0.3/js/bootstrap.min.js/script
102
103
104 script typetext/javascript srchttps://rawgithub.com/WickyNilliams/headroom.js/master/dist/headroom.js/script
105
106 script typetext/javascript srchttps://rawgithub.com/WickyNilliams/headroom.js/master/src/jQuery.headroom.js/script
107
108 script typetext/javascript
109
110 $(.navbar-fixed-top).headroom();
111
112 /script
113
114
115 /body
116 /html 原文地址:http://blog.csdn.net/chenyulearn/article/details/19606751 转载于:https://www.cnblogs.com/ccode/p/3905922.html