这篇文章主要介绍了纯CSS和jQuery实现的在页面顶部显示的进度条效果2例,仿手机浏览器进度条效果,分别使用纯CSS和jQuery实现,需要的朋友可以参考下
一、纯CSS实现
昨天在网上闲逛时,看到一个博客的页面最顶部有一个进度条特效,感觉挺好的,就分析了一下代码,找出了其中的关键部份,使用纯CSS实现的,给大家分享一下。
复制代码代码如下: <style type="text/css"> body{ margin:0; padding:0;} @-moz-keyframes progressing { 0% { width:0px; } 100% { width:100%; } } @-webkit-keyframes progressing { 0% { width:0px; } 100% { width:100%; } } .progress { width:100%; height:5px; overflow:hidden; background-color:#27ccc0; position:fixed; top:0; left:0; z-index:9; -moz-animation:progressing 2s ease-out; -webkit-animation:progressing 2s ease-out; } </style> <p class="progress"></p>
二、JQuery实现
一个在页面顶部显示的进度条效果,像在智能手机上浏览网页一样,手机上的浏览器进度条一般都在屏幕顶部,一条极细的小线条,当页面加载的时候,它就不断的加载显示进度,本网页进度条特效与此十分相似,基于jquery插件实现的效果。
复制代码代码如下: <title>页面顶部显示的进度条效果</title> <div id="web_loading"><div></div></div> <script src="/ajaxjs/jquery-1.7.2.min.js" type="text/javascript"></script> <script type="text/javascript">// < ![CDATA[ jQuery(document).ready(function(){ jQuery("#web_loading div").animate({width:"100%"},800,function(){ setTimeout(function(){jQuery("#web_loading div").fadeOut(500); }); }); }); // ]]></script> <style> #web_loading{ z-index:99999; width:100%; } #web_loading div{ width:0; height:5px; background:#FF9F15; } </style>
|