0


纯css实现 横向跑马灯(无缝滚动轮播,移入悬停)

效果
在这里插入图片描述

// App.js

  1. import React from 'react'import styles from './index.m.less'export default functionApp(){return(<div className={styles.container}style={{ display: 'flex'}}>{[1, 2, 3].map((k)=>(<div key={k} className={styles.content} style={{ display: 'flex', margin: '50px 0' }}>
  2. {Array.from({ length:12 },(_, idx)=> idx).map((i)=> {
  3. return (<a
  4. key={i}
  5. href='https://www.baidu.com/'
  6. style={{
  7. margin: '020px',
  8. padding: '20px 0',
  9. width: '220px',
  10. height: '100px',
  11. textAlign: 'center',
  12. border: '1px solid #f00'
  13. }}
  14. ><div style={{ fontSize: '80px' }}>{i +1}</div></a>)
  15. })}
  16. </div>))}</div>)}

// index.m.less

  1. .content {
  2. animation: marquee-left 20s linear infinite !important;}
  3. // 层级必须要这样写
  4. .container{&:hover{
  5. .content{
  6. // 暂停动画
  7. animation-play-state: paused !important;}}}
  8. @keyframes marquee-left {0% {
  9. transform: translate(0);}100% {
  10. transform: translate(-100%);}}
标签: css 前端

本文转载自: https://blog.csdn.net/qq_37034928/article/details/140843268
版权归原作者 讨口子 所有, 如有侵权,请联系我们删除。

“纯css实现 横向跑马灯(无缝滚动轮播,移入悬停)”的评论:

还没有评论