样式化的组件-为什么动画不起作用?

我们无法使该示例在React中使用样式化组件来工作。

为什么动画在我们的代码中不起作用?我无法让它动起来,不得不求助于使用普通的CSS来获得成功。在某个地方一定是一个简单的错误

import React from 'react'
import styled,{ keyframes } from 'styled-components'
import './ticker.css'





export default function Ticker({ text }) {
      return (<div class="ticker-wrap">
        <div class="ticker">
          <div class="ticker__item">Letterpress chambray brunch.</div>
          <div class="ticker__item">Vice mlkshk crucifix beard chillwave meditation hoodie asymmetrical Helvetica.</div>
          <div class="ticker__item">Ugh PBR&B kale chips Echo Park.</div>
          <div class="ticker__item">Gluten-free mumblecore chambray mixtape food truck. </div>
        </div>
      </div>)
    }


 @-webkit-keyframes ticker {
     0% {
    -webkit-transform: translate3d(0,0);
    transform: translate3d(0,0);
    visibility: visible;
    }
     100% {
    -webkit-transform: translate3d(-100%,0);
    transform: translate3d(-100%,0);
    }
}
 @keyframes ticker {
     0% {
    -webkit-transform: translate3d(0,0);
    }
}
 .ticker-wrap {
  position: fixed;
  bottom: 0;
  width: 100%;
  overflow: hidden;
  height: 4rem;
  background-color: #FDFCF8;
  padding-left: 100%;
  box-sizing: content-box;
}

.ticker-wrap .ticker {
  display: inline-block;
  height: 4rem;
  line-height: 4rem;
  white-space: nowrap;
  padding-right: 100%;
  box-sizing: content-box;
  -webkit-animation-iteration-count: infinite;
  animation-iteration-count: infinite;
  -webkit-animation-timing-function: linear;
  animation-timing-function: linear;
  -webkit-animation-name: ticker;
  animation-name: ticker;
  -webkit-animation-duration: 30s;
  animation-duration: 30s;
}
baitu1987 回答:样式化的组件-为什么动画不起作用?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2719282.html

大家都在问