Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 具有内联样式的关键帧_Html_Css_Reactjs - Fatal编程技术网

Html 具有内联样式的关键帧

Html 具有内联样式的关键帧,html,css,reactjs,Html,Css,Reactjs,我试图在ReactJS中设置脉动动画的关键帧。我试着在内联样式中设置关键帧,但这不起作用 如果您希望将所有样式与组件紧密耦合,请尝试使用样式化组件。他们有一个 e、 g 然后像这样使用: <Bar>I pulse</Bar> I脉冲 它可能重复,因为React无法知道脉冲动画。 .element { width: 100%; height: 100%; animation: pulse 5s infinite; } @keyframes pulse {

我试图在ReactJS中设置脉动动画的关键帧。我试着在内联样式中设置关键帧,但这不起作用


如果您希望将所有样式与组件紧密耦合,请尝试使用样式化组件。他们有一个

e、 g

然后像这样使用:

<Bar>I pulse</Bar>
I脉冲

它可能重复,因为React无法知道
脉冲
动画。
.element {
  width: 100%;
  height: 100%;
  animation: pulse 5s infinite;
}

@keyframes pulse {
  0% {
    background-color: #001F3F;
  }
  100% {
    background-color: #FF4136;
  }
}

html,
body {
  height: 100%;
}
import styled, { keyframes } from 'styled-components'

const pulse = keyframes`
  from {
    background-color: #001F3F;
  }

  to {
    background-color: #FF4136;
  }
`

const Bar = styled.div`
  color: #000;
  padding: 1em 0;
  font-size: 20px,
  text-align: center;
  cursor: pointer;
  position: fixed;
  bottom: '0',
  width: 100%;
  z-index: 10;
  animation: ${pulse} 1.2s ease-in-out;
  animation-iteration-count: infinite;
`
<Bar>I pulse</Bar>