簡體   English   中英

未能制作關鍵幀動畫

[英]failed to make keyframes animations

我試圖用 css 關鍵幀的圖像制作 slider 但它對我不起作用,這是代碼:

*{
  margin:0;
padding:0;
}

li {
   font-size: 20px;
margin: 10px;
  display : inline-block; } 

a {
   color: black;
   text-decoration: none;   }

a:hover {
    transform: scale(1.05);
}

li:hover {
    transform: scale(1.02);    }

ul li a {
    display: block;
    font-size: 25px;
    color: white ;
         }


.slider {
    min-height: 50vh;
    overflow: hidden;
    width: 100%;
    min-height: 90vh;
    background: url(../images/8.jpg);
    animation: 50s slider infinte;   }
  

  @keyframes slider {
      0% {background: url(../images/2.jpg);}
      25% { background: url(../images/3.jpg);}
     50% {background: url(../images/4.jpg);}
     65% { background: url(../images/5.jpg);}
     85% {background: url(../images/6.jpg);}
   100% {background: url(../images/7.png);}
  }

請注意: slider 它是一個 class 集成在 div 標簽中,在導航欄后為空。

您是否嘗試過使用“背景圖像”屬性而不僅僅是“背景”?

您滑塊的默認背景是../images/8.png但您給它0% {background: url(../images/2.jpg);} 那可能是個問題。 我認為默認值應該與 0% 關鍵幀相同

    .slider {
        min-height: 50vh;
        overflow: hidden;
        width: 100%;
        min-height: 90vh;
        background: url(../images/8.jpg);
        animation: 50s slider infinte;   }
      
    
      @keyframes slider {
          0% {background: url(../images/8.jpg);}
          25% { background: url(../images/3.jpg);}
         50% {background: url(../images/4.jpg);}
         65% { background: url(../images/5.jpg);}
         85% {background: url(../images/6.jpg);}
       100% {background: url(../images/7.png);}
      }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM