Chinaunix首页 | 论坛 | 博客
  • 博客访问: 76675
  • 博文数量: 73
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 740
  • 用 户 组: 普通用户
  • 注册时间: 2014-07-04 16:50
文章分类
文章存档

2014年(73)

我的朋友

分类: Html/Css

2014-08-16 10:36:56

  • CSS3实现进度条代码,演示不同百分比时候的进度条状态,无刷新改变进度条的长度,兼容主流浏览器,欢迎下载。

点击(此处)折叠或打开

  1. <!DOCTYPE html>

  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5.     <title></title>
  6.     <style>
  7.         body {
  8.              
  9.     font: 13px 'trebuchet MS',Arial,Helvetica;
  10.         }
  11.     
  12.         h2, p {
  13.             text-align: center;
  14.             color: #fafafa;
  15.             text-shadow: 0 1px 0 #111;    
  16.         }
  17.         
  18.         a {
  19.             color: #777;
  20.         }

  21.         .progress-bar {
  22.             background-color: #1a1a1a;
  23.             height: 25px;
  24.             padding: 5px;
  25.             width: 350px;
  26.             margin: 70px 0 20px 0;            
  27.             -moz-border-radius: 5px;
  28. -webkit-border-radius: 5px;
  29. border-radius: 5px;
  30.             -moz-box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444;
  31.             -webkit-box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444;
  32.             box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444;
  33.         }
  34.         
  35.         .progress-bar span {
  36.             display: inline-block;
  37.             height: 100%;
  38.             background-color: #777;
  39.             -moz-border-radius: 3px;
  40.             -webkit-border-radius: 3px;
  41.             border-radius: 3px;
  42.             -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset;
  43.             -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset;
  44.             box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset;
  45.             -webkit-transition: width .4s ease-in-out;
  46.             -moz-transition: width .4s ease-in-out;
  47.             -ms-transition: width .4s ease-in-out;
  48.             -o-transition: width .4s ease-in-out;
  49.             transition: width .4s ease-in-out;        
  50.         }
  51.         
  52.         /*---------------------------*/            
  53.         
  54.         .blue span {
  55.             background-color: #34c2e3;
  56.         }

  57.         .orange span {
  58.              background-color: #fecf23;
  59.              background-image: -webkit-gradient(linear, left top, left bottom, from(#fecf23), to(#fd9215));
  60.              background-image: -webkit-linear-gradient(top, #fecf23, #fd9215);
  61.              background-image: -moz-linear-gradient(top, #fecf23, #fd9215);
  62.              background-image: -ms-linear-gradient(top, #fecf23, #fd9215);
  63.              background-image: -o-linear-gradient(top, #fecf23, #fd9215);
  64.              background-image: linear-gradient(top, #fecf23, #fd9215);
  65.         }    

  66.         .green span {
  67.              background-color: #a5df41;
  68.              background-image: -webkit-gradient(linear, left top, left bottom, from(#a5df41), to(#4ca916));
  69.              background-image: -webkit-linear-gradient(top, #a5df41, #4ca916);
  70.              background-image: -moz-linear-gradient(top, #a5df41, #4ca916);
  71.              background-image: -ms-linear-gradient(top, #a5df41, #4ca916);
  72.              background-image: -o-linear-gradient(top, #a5df41, #4ca916);
  73.              background-image: linear-gradient(top, #a5df41, #4ca916);
  74.         }        
  75.         
  76.         /*---------------------------*/        
  77.         
  78.         .stripes span {
  79.             -webkit-background-size: 30px 30px;
  80.             -moz-background-size: 30px 30px;
  81.             background-size: 30px 30px;            
  82.             background-image: -webkit-gradient(linear, left top, right bottom,
  83.                                 color-stop(.25, rgba(255, 255, 255, .15)), color-stop(.25, transparent),
  84.                                 color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .15)),
  85.                                 color-stop(.75, rgba(255, 255, 255, .15)), color-stop(.75, transparent),
  86.                                 to(transparent));
  87.             background-image: -webkit-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
  88.                                 transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
  89.                                 transparent 75%, transparent);
  90.             background-image: -moz-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
  91.                                 transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
  92.                                 transparent 75%, transparent);
  93.             background-image: -ms-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
  94.                                 transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
  95.                                 transparent 75%, transparent);
  96.             background-image: -o-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
  97.                                 transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
  98.                                 transparent 75%, transparent);
  99.             background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
  100.                                 transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
  101.                                 transparent 75%, transparent);
  102.             
  103.             -webkit-animation: animate-stripes 3s linear infinite;
  104.             -moz-animation: animate-stripes 3s linear infinite;         
  105.         }
  106.         
  107.         @-webkit-keyframes animate-stripes {
  108.             0% {background-position: 0 0;} 100% {background-position: 60px 0;}
  109.         }
  110.         
  111.         
  112.         @-moz-keyframes animate-stripes {
  113.             0% {background-position: 0 0;} 100% {background-position: 60px 0;}
  114.         }
  115.         
  116.         /*---------------------------*/    

  117.         .shine span {
  118.             position: relative;
  119.         }
  120.         
  121.         .shine span::after {
  122.             content: '';
  123.             opacity: 0;
  124.             position: absolute;
  125.             top: 0;
  126.             right: 0;
  127.             bottom: 0;
  128.             left: 0;
  129.             background: #fff;
  130.             -moz-border-radius: 3px;
  131.             -webkit-border-radius: 3px;
  132.             border-radius: 3px;            
  133.             
  134.             -webkit-animation: animate-shine 2s ease-out infinite;
  135.             -moz-animation: animate-shine 2s ease-out infinite;             
  136.         }

  137.         @-webkit-keyframes animate-shine {
  138.             0% {opacity: 0; width: 0;}
  139.             50% {opacity: .5;}
  140.             100% {opacity: 0; width: 95%;}
  141.         }
  142.         
  143.         
  144.         @-moz-keyframes animate-shine {
  145.             0% {opacity: 0; width: 0;}
  146.             50% {opacity: .5;}
  147.             100% {opacity: 0; width: 95%;}
  148.         }

  149.         /*---------------------------*/    
  150.         
  151.         .glow span {
  152.             -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;
  153.             -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;
  154.             box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;
  155.             
  156.             -webkit-animation: animate-glow 1s ease-out infinite;
  157.             -moz-animation: animate-glow 1s ease-out infinite;             
  158.         }

  159.         @-webkit-keyframes animate-glow {
  160.          0% { -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;}
  161.          50% { -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .3) inset, 0 -5px 5px rgba(255, 255, 255, .3) inset;}
  162.          100% { -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;}
  163.          }

  164.         @-moz-keyframes animate-glow {
  165.          0% { -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;}
  166.          50% { -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .3) inset, 0 -5px 5px rgba(255, 255, 255, .3) inset;}
  167.          100% { -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;}
  168.          }
  169.     </style>
  170. </head>

  171. <body style='margin:100px 10px;'>
  172. <div style=" width:360px; margin:0 auto">
  173. <br><br>

  174. <h1>CSS3打造的进度条</h1>

  175. <div class="progress-bar blue stripes">
  176.     <span style="width: 40%"></span>
  177.   
  178. </div>
  179. <p>Set above to:
  180.     <a href="#" class="quarter">25%</a> /
  181.     <a href="#" class="half">50%</a> /
  182.     <a href="#" class="three-quarters">75%</a> /
  183.     <a href="#" class="full">100%</a>

  184. </p>

  185. <div class="progress-bar orange shine">
  186.     <span style="width: 65%"></span>
  187. </div>
  188. <p>Set above to:
  189.     <a href="#" class="quarter">25%</a> /
  190.     <a href="#" class="half">50%</a> /
  191.     <a href="#" class="three-quarters">75%</a> /
  192.     <a href="#" class="full">100%</a>

  193. </p>

  194. <div class="progress-bar green glow">
  195.     <span style="width: 55%"></span>
  196. </div>
  197. <p>Set above to:
  198.     <a href="#" class="quarter">25%</a> /
  199.     <a href="#" class="half">50%</a> /
  200.     <a href="#" class="three-quarters">75%</a> /
  201.     <a href="#" class="full">100%</a>

  202. </p>
  203. </div>
  204. <script src=""></script>
  205. <script>
  206.     $(document).ready(function(){
  207.         $('.quarter').click(function(){
  208.             $(this).parent().prev().children('span').css('width','25%');
  209.             });
  210.         $('.half').click(function(){
  211.             $(this).parent().prev().children('span').css('width','50%');
  212.             });
  213.         $('.three-quarters').click(function(){
  214.             $(this).parent().prev().children('span').css('width','75%');
  215.             });
  216.         $('.full').click(function(){
  217.             $(this).parent().prev().children('span').css('width','100%');
  218.             });            
  219.     });
  220. </script>
  221. </body>
  222. </html>


阅读(257) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~