> 웹 프론트엔드 > CSS 튜토리얼 > CSS3 및 jquery로 구현된 그라데이션 동적 진행률 표시줄

CSS3 및 jquery로 구현된 그라데이션 동적 진행률 표시줄

高洛峰
풀어 주다: 2016-11-24 09:40:15
원래의
1587명이 탐색했습니다.

진행률 표시줄은 일반적인 유형의 웹사이트입니다. 오늘은 외국 웹사이트의 예를 연구한 후 CSS3를 사용하여 진행률 표시줄을 구현해 보았습니다.

html 코드는 다음과 같습니다. 다음과 같습니다:

    <div class="progress-bar blue stripes">
    <span style="width: 40%"></span>
</div>
<p>Set above to:
    <a href="http://www.php1.cn/">
    <a href="http://www.php1.cn/">
    <a href="http://www.php1.cn/">
    <a href="http://www.php1.cn/">
</p>
 
<div class="progress-bar orange shine">
    <span style="width: 65%"></span>
</div>
<p>Set above to:
    <a href="http://www.php1.cn/">
    <a href="http://www.php1.cn/">
    <a href="http://www.php1.cn/">
    <a href="http://www.php1.cn/">
</p>
 
<div class="progress-bar green glow">
    <span style="width: 55%"></span>
</div>
<p>Set above to:
    <a href="http://www.php1.cn/">
    <a href="http://www.php1.cn/">
    <a href="http://www.php1.cn/">
    <a href="http://www.php1.cn/">
</p>
로그인 후 복사

css 스타일:

body{ background:#222; width:360px; margin:0 auto; font:13px &#39;trebuchet MS&#39;,Arial,Helvetica;}
h2, p {text-align: center;color: #fafafa;text-shadow: 0 1px 0 #111;    }
 a {color: #777;}
 
 .progress-bar{ background-color:#1a1a1a; height:25px; padding:5px; width:350px; margin:70px 0 20px 0;-moz-border-radius:5px; -webkit-border-raidus:5px; border-radius:5px;-moz-box-shadow:0 1px 5px #000 inset, 0 1px 0 #444;-webkit-box-shadow:0 1px 5px #1a1a1a inset,0 1px 0 #444; box-shadow:0 1px 5px inset,0 1px 0 #444;  }
.progress-bar span{ display:inline-block; height:100%; background-color:#777; -moz-border-radius:3px;-webkit-border-radius:3px; border-radius:3px; border-radius:3px; box-shadow:0 1px 0 rgba(255,255,255,.5) inset; -webkit-box-shadow:0 1px 0 rgba(255,255,.5) inset; -moz-box-shadow:0 1px 0 rgba(255,255,.5) inset;  -webkit-transition:width .4s ease-in-out; -moz-transition:width .4s ease-in-out;-ms-transition:width .4s ease-in-out;transition: width .4s ease-in-out;    }
로그인 후 복사

주로 진행률 표시줄의 배경을 구현합니다:

.blue span {
            background-color: #34c2e3;   
        }
.orange span{
     background-color:#fecf23;
     background-image:-webkit-gradient(linear,left top,left bottom,from(#fecf23), to(#fd9215));
     background-image:-webkit-linear-gradient(top,#fecf23, #fd9215);
     background-image:-moz-linear-gradient(top,#fecf23, #fd9215);
     background-image:-ms-linear-gradient(top, #fecf23, #fd9215);
     background-image:-o-linear-gradient(top, #fecf23, #fd9215);
     background-image: linear-gradient(top, #fecf23, #fd9215);  
   filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=&#39;#fecf23&#39;, endColorstr=&#39;#fd9215&#39;); /* IE6 & IE7 */
   -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=&#39;#fecf23&#39;, endColorstr=&#39;#fd9215&#39;)"; /* IE8 */ 
 
    }
    .green span{
        background-color:#a5df41;
        background-image:-webkit-gradient(linear,left top,left bottom,from(#a5df41), to(#4ca916));
        background-image:-webkit-linear-gradient(top,#a5df41, #4ca916);
        background-image:-moz-linear-gradient(top,#a5df41, #4ca916);
        background-image: -ms-linear-gradient(top, #a5df41, #4ca916);
        background-image: -o-linear-gradient(top, #a5df41, #4ca916);
        background-image: linear-gradient(top, #a5df41, #4ca916);  
       filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=&#39;#a5df41&#39;, endColorstr=&#39;#4ca916&#39;); /* IE6 & IE7 */
       -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=&#39;#a5df41&#39;, endColorstr=&#39;#4ca916&#39;)"; /* IE8 */  
 
 }
        .stripes span {
            -webkit-background-size: 30px 30px;
            -moz-background-size: 30px 30px;
            background-size: 30px 30px;            
            background-image: -webkit-gradient(linear, left top, right bottom,
                                color-stop(.25, rgba(255, 255, 255, .15)), color-stop(.25, transparent),
                                color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .15)),
                                color-stop(.75, rgba(255, 255, 255, .15)), color-stop(.75, transparent),
                                to(transparent));
            background-image: -webkit-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
                                transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
                                transparent 75%, transparent);
            background-image: -moz-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
                                transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
                                transparent 75%, transparent);
            background-image: -ms-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
                                transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
                                transparent 75%, transparent);
            background-image: -o-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
                                transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
                                transparent 75%, transparent);
            background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
                                transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
                                transparent 75%, transparent);            
            
            -webkit-animation: animate-stripes 3s linear infinite;
            -moz-animation: animate-stripes 3s linear infinite;               
        }
        @-webkit-keyframes animate-stripes { 
            0% {background-position: 0 0;} 100% {background-position: 60px 0;}
        }
        
        
        @-moz-keyframes animate-stripes {
            0% {background-position: 0 0;} 100% {background-position: 60px 0;}
        }
        .shine span {
            position: relative;
        }
        
        .shine span::after {
            content: &#39;&#39;;
            opacity: 0;
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            background: #fff;
            -moz-border-radius: 3px;
            -webkit-border-radius: 3px;
            border-radius: 3px;            
            
            -webkit-animation: animate-shine 2s ease-out infinite;
            -moz-animation: animate-shine 2s ease-out infinite;             
        }
 
        @-webkit-keyframes animate-shine { 
            0% {opacity: 0; width: 0;}
            50% {opacity: .5;}
            100% {opacity: 0; width: 95%;}
        }
        
        
        @-moz-keyframes animate-shine {
            0% {opacity: 0; width: 0;}
            50% {opacity: .5;}
            100% {opacity: 0; width: 95%;}
        }
 
        /*---------------------------*/     
        
        .glow span {
            -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;
            -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;
            box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;
            
            -webkit-animation: animate-glow 1s ease-out infinite;
            -moz-animation: animate-glow 1s ease-out infinite;             
        }
        @-webkit-keyframes animate-glow {
         0% { -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;}
         50% { -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .3) inset, 0 -5px 5px rgba(255, 255, 255, .3) inset;}
         100% { -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;}
         }
        @-moz-keyframes animate-glow {
         0% { -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;}
         50% { -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .3) inset, 0 -5px 5px rgba(255, 255, 255, .3) inset;}
         100% { -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;}
         }
로그인 후 복사

jquey 부분:

$(document).ready(function(){
    $(&#39;.quarter&#39;).click(function(){
        $(this).parent().prev().children("span").css(&#39;width&#39;,&#39;25%&#39;);
        });
        $(&#39;.half&#39;).click(function(){
            $(this).parent().prev().children(&#39;span&#39;).css("width",&#39;50%&#39;);
            });
            $(&#39;.three-quarters&#39;).click(function(){
                $(this).parent().prev().children(&#39;span&#39;).css(&#39;width&#39;,&#39;75%&#39;);
                });
                $(&#39;.full&#39;).click(function(){
                    $(this).parent().prev().children(&#39;span&#39;).css(&#39;width&#39;,&#39;100%&#39;);
                    })
    })
로그인 후 복사


관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿