3

I want to make a game. How can I make a h1 tag move left to right in reactjs ?

import React from 'react';

const Hello = (props) => (<React.StrictMode><h1 className = "App">Hello {props.name}</h1></React.StrictMode>);

export default Hello;
Umut Arpat
  • 454
  • 1
  • 6
  • 18
  • This is not a React task, it is CSS mainly. Try this https://stackoverflow.com/questions/10679367/css-moving-text-from-left-to-right – rotimi-best May 03 '20 at 16:56

1 Answers1

1

I created this solution: codepen:

const App = () => {
    return (
      <div className="wrapper">
        <p className="marquee">Hello, world!</p>
      </div>
    );
}

  ReactDOM.render(
    <App />,
    document.getElementById('root')
  );

css file:

body{ 
    overflow: hidden;
}
p{
    position: absolute;
    white-space: nowrap;
    animation: floatText 5s infinite alternate ease-in-out;
}

@-webkit-keyframes floatText{
  from {
    left: 00%;
  }

  to {
    /* left: auto; */
    left: 100%;
  }
}
Ibraheem Ahmed
  • 11,652
  • 2
  • 48
  • 54