簡體   English   中英

理解CSS中的關鍵幀時遇到問題

[英]Problem understanding the keyframes in css

我有以下關鍵幀,我想通過這些關鍵幀來制作Windows徽標的動畫:

.box {
  height: 40px;
  width: 40px;
  float: left;
}

#box1 {
  #background-color: red;
  animation: box1 4s 1s infinite;
}

#box2 {
  #background-color: lightgreen;
  animation: box2 4s 1s infinite;

}

@keyframes box2 {
   0% {
    background-color: #1b2028;
  }
  25% {
    background-color:  #1b2028;
  }
  50% {
    background-color: #1b2028;
  }
  75% {
    background-color: lightgreen;
  100% {
    background-color: #1b2028;
  }

}

@keyframes box1 {
  0% {
    background-color: red;
  }
  25% {
    background-color: red;
  }
  50% {
    background-color: red;
  }
  75% {
    background-color: red;
  100% {
    background-color: #1b2028;
  }
}

但是,問題僅在於關鍵幀之一正在工作。 即只有名稱為box2的關鍵幀有效,而當我將box1的關鍵幀放在頂部時有效,為什么會這樣。 有人可以為我提供關鍵幀的很好的理解嗎? 指向codepen的鏈接是: https ://codepen.io/theredcap/pen/qvJdJa ? editors = 1100

您是否用棉短絨檢查了CSS? CSS皮棉發現了4個錯誤和6個警告。

修正以下錯誤。

  • 預期RBRACE位於第54行第9行。
  • 預期RBRACE位於第72行第9行。
  • 預期RBRACE位於第90行第9行。
  • 預計RBRACE在第107行第9行。

您缺少結束符} :)

檢查此代碼筆: https ://codepen.io/foxfabi/pen/oVaePr

暫無
暫無

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

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