<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ?CSS3的新特性為我們實現漂亮的進度條掃清了障礙,我們可以完全不需要任何圖片和簡單的Javascript代碼就可以構建。 **一、第一個例子** ?效果圖: ![](https://box.kancloud.cn/2016-08-02_57a05bd982f66.gif) ?Demo地址:[http://namepk.sinaapp.com/demo/progress.html](http://namepk.sinaapp.com/demo/progress.html)。 1、? 基本的HTML ?HTML代碼非常簡單: ~~~ <div id="loading-status"> <div id="precent"></div> </div>? ~~~ ?loading-status表示外層的容器,precent表示進度條。 2、? CSS代碼 ~~~ #loading-status { width: 300px; border: 1px #669CB8 solid; -webkit-box-shadow: 0px 2px 2px #D0D4D6; height: 15px; -webkit-border-radius: 10px; background: -webkit-gradient(linear, 0 0, 0 100%, from(#E1E9EE), to(white)); padding: 1px;}? ~~~ ?我們為外層容器添加了邊框、圓角、陰影和漸變背景,效果如下圖所示: ![](https://box.kancloud.cn/2016-08-02_57a05bd994dad.gif) ?進度條的CSS代碼如下: ~~~ #process { background: -webkit-gradient(linear, 0 0, 0 100%, from(#7BC3FF), color-stop(0.5,#42A9FF), to(#7BC3FF)); width: 0%; height: 100%; -webkit-border-radius: 10px;}? ~~~ ?將width修改為10%可以看到效果: ![](https://box.kancloud.cn/2016-08-02_57a05bd9a8621.gif) 3、動畫 ?通過控制width的百分比就可以控制進度條的顯示,動畫用CSS3的animation或者transition都可以實現,這里我們選擇animation: ~~~ #process { background: -webkit-gradient(linear, 0 0, 0 100%, from(#7BC3FF), color-stop(0.5,#42A9FF), to(#7BC3FF)); width: 0%; height: 100%; -webkit-border-radius: 10px; -webkit-transition: width 1s ease-in-out;}? ~~~ ?然后我們通過Javascript來控制precent元素的寬度就可以實現進度條的動畫效果了: ~~~ Jquery: $(‘#precent’).width(‘80%’)Javascript: document.getElementById(‘precent’).style.width = ‘80%’? ~~~ **二、第二個例子** ?下面我們實現一個更為復雜一點的進度條: ![](https://box.kancloud.cn/2016-08-02_57a05bd9ba7fc.gif) ?Demo地址:[http://namepk.sinaapp.com/demo/progress.html](http://namepk.sinaapp.com/demo/progress.html)。 1、基本的HTML ~~~ <div class="box animate"> <span> <span></span> </span> </div>? ~~~ ?一共是三個元素。 2、? CSS樣式 ~~~ .box { height: 20px; position: relative; background: hsl(0, 0%, 35%); -webkit-border-radius: 15px; padding: 6px; -webkit-box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.3); width: 300px; }? ~~~ ?外框樣式如下所示: ![](https://box.kancloud.cn/2016-08-02_57a05bd9ced72.gif) ~~~ .box > span { display: block; height: 100%; -webkit-border-top-right-radius: 8px; -webkit-border-bottom-right-radius: 8px; -webkit-border-top-left-radius: 15px; -webkit-border-bottom-left-radius: 15px; background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #63DE4E), color-stop(1, #34A702)); -webkit-box-shadow: inset 0 2px 9px rgba(255,255,255,0.3), inset 0 -2px 6px rgba(0,0,0,0.4); position: relative; overflow: hidden; }? ~~~ ?基本進度條樣式如下所示: ![](https://box.kancloud.cn/2016-08-02_57a05bd9e5420.gif) ?為內層的span定義的樣式如下,主要是設定了一個漸變的背景。 ~~~ .animate > span > span { content: ""; position: absolute; top: 0;left: 0;bottom: 0;right: 0; background-image: -webkit-gradient(linear, 0 0, 100% 100%, color-stop(.25, rgba(255, 255, 255, .2)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .2)), color-stop(.75, rgba(255, 255, 255, .2)), color-stop(.75, transparent), to(transparent)); z-index: 2; -webkit-border-top-right-radius: 8px; -webkit-border-bottom-right-radius: 8px; -webkit-border-top-left-radius: 20px; -webkit-border-bottom-left-radius: 20px; overflow: hidden; }? ~~~ ?樣式如下: ![](https://box.kancloud.cn/2016-08-02_57a05bda04e2e.gif) ?我們還需要添加一個屬性: -webkit-background-size: 40px;? ?現在效果如下圖所示: ![](https://box.kancloud.cn/2016-08-02_57a05bda1ce74.gif) 3、? 動畫 ?動畫我們通過改變background-position來實現。代碼如下: ~~~ .animate > span span { content: ""; position: absolute; top: 0; left: 0; bottom: 0; right: 0; background-image: -webkit-gradient(linear, 0 0, 100% 100%, color-stop(.25, rgba(255, 255, 255, .2)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .2)), color-stop(.75, rgba(255, 255, 255, .2)), color-stop(.75, transparent), to(transparent)); z-index: 2; -webkit-background-size: 40px; -webkit-animation: move 2s linear infinite; -webkit-border-top-right-radius: 8px; -webkit-border-bottom-right-radius: 8px; -webkit-border-top-left-radius: 20px; -webkit-border-bottom-left-radius: 20px; overflow: hidden; } @-webkit-keyframes move { 0% { background-position: 0 0; } 100% { background-position: 50px 50px; } }? ~~~ ?最終的效果如下: ![](https://box.kancloud.cn/2016-08-02_57a05bd9ba7fc.gif) ?寫在最后:由我擔任作者的一本HTML5入門書籍正在策劃和寫作中,大家可以期待一下,呵呵。 ![](https://box.kancloud.cn/2016-08-02_57a05bda3ce5b.gif)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看