screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState } = React; function App() { const [randomNum, setRandomNum] = useState(null); const generateRandomNumber = () => { const min = 50; const max = 100; const newRandomNum = Math.floor(Math.random() * (max - min + 1)) + min; setRandomNum(newRandomNum); }; return ( <div className='container'> <h3>React Js Generate Random Number between 50 -100</h3> <p className='random-number'> Random Number Between 50 and 100: {randomNum} </p> <button className='generate-button' onClick={generateRandomNumber}> Generate </button> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { max-width: 500px; margin: 0 auto; padding: 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); display: flex; flex-direction: column; align-items: center; justify-content: center; } h3 { color: #333; } .random-number { font-size: 24px; margin: 20px 0; color: #0074cc; } .generate-button { background-color: #0074cc; color: #fff; border: none; padding: 10px 20px; font-size: 16px; border-radius: 5px; cursor: pointer; } .generate-button:hover { background-color: #005aa6; } </style> </body> </html>