溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

使用CSS3怎么實(shí)現(xiàn)一個(gè)時(shí)間軸效果

發(fā)布時(shí)間:2021-04-20 16:38:59 來源:億速云 閱讀:171 作者:Leah 欄目:web開發(fā)

這篇文章將為大家詳細(xì)講解有關(guān)使用CSS3怎么實(shí)現(xiàn)一個(gè)時(shí)間軸效果 ,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。

什么是css

css是一種用來表現(xiàn)HTML或XML等文件樣式的計(jì)算機(jī)語言,主要是用來設(shè)計(jì)網(wǎng)頁的樣式,使網(wǎng)頁更加美化。它也是一種定義樣式結(jié)構(gòu)如字體、顏色、位置等的語言,并且css樣式可以直接存儲(chǔ)于HTML網(wǎng)頁或者單獨(dú)的樣式單文件中,而樣式規(guī)則的優(yōu)先級(jí)由css根據(jù)這個(gè)層次結(jié)構(gòu)決定,從而實(shí)現(xiàn)級(jí)聯(lián)效果,發(fā)展至今,css不僅能裝飾網(wǎng)頁,也可以配合各種腳本對(duì)于網(wǎng)頁進(jìn)行格式化。

HTML結(jié)構(gòu):

XML/HTML Code復(fù)制內(nèi)容到剪貼板

  1. <div class="timezone">  

  2.             <div class="time">  

  3.                 <h3>2015-07-02</h3>  

  4.                 <div>  

  5.                     <p>暴走大事件第一季</p>  

  6.                     <ul>  

  7.   

  8.                     </ul>  

  9.                 </div>  

  10.             </div>  

  11.             <div class="timeLeft" style="top: 100px;">  

  12.                 <h3>2015-07-02</h3>  

  13.                 <div>  

  14.                     <p>暴走大事件第二季</p>  

  15.                     <ul>  

  16.   

  17.                     </ul>  

  18.                 </div>  

  19. </div>    

  20.   

這里簡(jiǎn)化了一下HTML結(jié)構(gòu),.time類表示在右邊,.timeLeft表示在左邊,然后加點(diǎn)上外邊距就可以了,每一塊里面的內(nèi)容我就刪減掉了。
 
CSS樣式代碼如下:

CSS Code復(fù)制內(nèi)容到剪貼板

  1. body{   

  2.                 background#333;   

  3.             }   

  4.             h2{   

  5.                 text-aligncenter;   

  6.                 color:#fff;   

  7.             }   

  8.             .timezone{   

  9.                 width:6px;   

  10.                 height350px;   

  11.                 background: lightblue;   

  12.                 margin: 0 auto;   

  13.                 margin-top:50px;   

  14.                 border-radius: 3px;   

  15.                 positionrelative;   

  16.                 -webkit-animation: heightSlide 2s linear;   

  17.             }   

  18.             @-webkit-keyframes heightSlide{   

  19.                 0%{   

  20.                     height: 0;   

  21.                 }   

  22.                 100%{   

  23.                     height350px;   

  24.                 }   

  25.             }   

  26.             .timezone:after{   

  27.                 content'未完待續(xù)...';   

  28.                 width100px;   

  29.                 color:#fff;   

  30.                 positionabsolute;   

  31.                 margin-left: -35px;   

  32.                 bottombottom: -30px;   

  33.                 -webkit-animation: showIn 4s ease;   

  34.             }   

  35.             .timezone .time,.timezone .timeLeft{   

  36.                 positionabsolute;   

  37.                 margin-left: -10px;   

  38.                 margin-top:-10px;   

  39.                 width:20px;   

  40.                 height:20px;   

  41.                 border-radius: 50%;   

  42.                 border:4px solid rgba(255,255,255,0.5);   

  43.                 background: lightblue;   

  44.                 -webkit-transition: all 0.5s;   

  45.                 -webkit-animation: showIn ease;   

  46.             }   

  47.             .timezone .time:nth-child(1){   

  48.                 -webkit-animation-duration:1s;   

  49.             }   

  50.             .timezone .timeLeft:nth-child(2){   

  51.                 -webkit-animation-duration:1.5s;   

  52.             }   

  53.             .timezone .time:nth-child(3){   

  54.                 -webkit-animation-duration:2s;   

  55.             }   

  56.             .timezone .timeLeft:nth-child(4){   

  57.                 -webkit-animation-duration:2.5s;   

  58.             }   

  59.             @-webkit-keyframes showIn{   

  60.                 0%,70%{   

  61.                     opacity: 0;   

  62.                 }   

  63.                 100%{   

  64.                     opacity: 1;   

  65.                 }   

  66.             }   

  67.             .timezone .time h3,.timezone .timeLeft h3{   

  68.                 positionabsolute;   

  69.                 margin-left: -120px;   

  70.                 margin-top3px;   

  71.                 color:#eee;   

  72.                 font-size14px;   

  73.                 cursor:pointer;   

  74.                 -webkit-animation: showIn 3s ease;   

  75.             }   

  76.             .timezone .timeLeft h3{   

  77.                 margin-left60px;   

  78.                 width100px;   

  79.             }   

  80.             .timezone .time:hover,.timezone .timeLeft:hover{   

  81.                 border:4px solid lightblue;   

  82.                 background: lemonchiffon;   

  83.                 box-shadow: 0 0 2px 2px rgba(255,255,255,0.4);   

  84.             }   

  85.             .timezone .time div,.timezone .timeLeft div{   

  86.                 positionabsolute;   

  87.                 top:50%;   

  88.                 margin-top: -25px;   

  89.                 left:50px;   

  90.                 width300px;   

  91.                 height50px;   

  92.                 background: lightblue;   

  93.                 border:3px solid #eee;   

  94.                 border-radius: 10px;   

  95.                 z-index: 2;   

  96.                 overflowhidden;   

  97.                 cursor:pointer;   

  98.                 -webkit-animation: showIn 3s ease;   

  99.                 -webkit-transition: all 0.5s;   

  100.             }   

  101.             .timezone .timeLeft div{   

  102.                 left:-337px;   

  103.             }   

  104.             .timezone .time div:hover,.timezone .timeLeft div:hover{   

  105.                 height170px;   

  106.             }   

  107.             .timezone .time div p,.timezone .timeLeft div p{   

  108.                 color#fff;   

  109.                 font-weightbold;   

  110.                 text-aligncenter;   

  111.             }   

  112.             .timezone .time:before,.timezone .timeLeft:before{   

  113.                 content'';   

  114.                 positionabsolute;   

  115.                 top:0px;   

  116.                 left32px;   

  117.                 width0px;   

  118.                 height0px;   

  119.                 border:10px solid transparent;   

  120.                 border-right:10px solid #eee;   

  121.                 z-index:-1;   

  122.                 -webkit-animation: showIn 3s ease;   

  123.             }   

  124.             .timezone .timeLeft:before{   

  125.                 left:-33px;   

  126.                 border:10px solid transparent;   

  127.                 border-left:10px solid #eee;   

  128.             }   

  129.             .timezone .time div ul,.timezone .timeLeft div ul{   

  130.                 list-stylenone;   

  131.                 width:300px;   

  132.                 padding:5px 0 0;   

  133.                 border-top:2px solid #eee;   

  134.                 color:#fff;   

  135.                 text-aligncenter;   

  136.             }   

  137.             .timezone .time div li,.timezone .timeLeft div li{   

  138.                 displayinline-block;   

  139.                 height25px;   

  140.                 line-height25px;   

  141.             }    

  142.   

關(guān)于使用CSS3怎么實(shí)現(xiàn)一個(gè)時(shí)間軸效果 就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI