styled-components实现 CSS in JS

伪类选择器(:hover/:focus等)

使用 styled-components 可以实现CSS中:hover,:focus,:active等效果

const ImgUrl = styled.a`
  font-size: 12px;

  &:hover {
    color: #42b983;
  }
`;

动画 @keyframe

使用 styled-components 同样可以实现 CSS动画 @keyframe

const change= keyframes`
  0%{
    width:100px;
  }
  50% {
    width:30px;
  }
 100%{
    width:70px;
  } 
`;
const ShowAnimation = styled.div`
   width:100px;
   height:100px;

  &:hover {
    animation: ${change} 2s linear infinite;
  }
`;
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容