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 [number, setNumber] = useState(0); const [result, setResult] = useState(''); const checkNumber = () => { if (Number.isInteger(number)) { if (number > 0) { setResult('Positive Integer'); } else if (number < 0) { setResult('Negative Integer'); } else { setResult('Zero'); } } else { setResult('Not an Integer'); } }; return ( <div className='container'> <h3>React Js Check Positive/Negative Integer Checker</h3> <input type="number" placeholder="Enter a number" value={number} onChange={(e) => setNumber(parseInt(e.target.value))} /> <button onClick={checkNumber}>Check</button> <p>{result}</p> </div> ); } ReactDOM.render(<App />, document.getElementById('app')); </script> <style> /* Container */ .container { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); text-align: center; } h3 { font-size: 24px; color: #333; margin-bottom: 20px; } input[type="number"] { width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 5px; font-size: 16px; } button { background-color: #007bff; color: #fff; border: none; border-radius: 5px; padding: 10px 20px; font-size: 16px; cursor: pointer; transition: background-color 0.3s; } button:hover { background-color: #0056b3; } p { font-size: 18px; margin-top: 10px; font-weight: bold; color: #333; } </style> </body> </html>