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 [hexString, setHexString] = useState('ff00'); const [decimalValue, setDecimalValue] = useState(0); const handleInputChange = (event) => { const inputHex = event.target.value; const decimal = parseInt(inputHex, 16); setHexString(inputHex); setDecimalValue(decimal); }; return ( <div className='container'> <h3>React Js Convert hex string into int</h3> <input type="text" placeholder="Enter Hexadecimal String" value={hexString} onInput={handleInputChange} /> <p>Decimal Value: {decimalValue}</p> </div> ); } ReactDOM.render(<App />, document.getElementById('app')); </script> <style> .container { width: 600px; margin: 0 auto; box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px, rgba(0, 0, 0, 0.06) 0px 2px 4px -1px; padding: 20px; } h3 { font-size: 24px; color: #333; margin-bottom: 20px; } input { width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 5px; font-size: 16px; box-sizing: border-box; } input::placeholder { color: #999; } p { font-size: 18px; color: #555; } </style> </body> </html>