screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://unpkg.com/react@17.0.2/umd/react.development.js"></script> <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.development.js"></script> <script src="https://unpkg.com/@babel/standalone@7.14.7/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState } = React; function App() { const [celsius, setCelsius] = useState(''); const [fahrenheit, setFahrenheit] = useState(''); const handleCelsiusChange = (e) => { const celsiusValue = e.target.value; setCelsius(celsiusValue); const fahrenheitValue = (celsiusValue * 9) / 5 + 32; setFahrenheit(fahrenheitValue.toFixed(2)); }; return ( <div className="container"> <h3 className="title">React JS Convert Celsius to Fahrenheit</h3> <label className="label">Celsius:</label> <input className="input" type="number" value={celsius} onChange={handleCelsiusChange} /> <br /> <label className="label">Fahrenheit:</label> <input className="input" type="number" value={fahrenheit} readOnly /> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { text-align: center; margin: 0 auto; width: 700px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); display: flex; flex-direction: column; align-items: center; } .title { font-size: 24px; margin-bottom: 20px; } .label { font-weight: bold; } .input { padding: 5px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 3px; width: 200px; } .input:focus { outline: none; box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); } </style> </body> </html>