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 [fahrenheit, setFahrenheit] = useState(''); const [celsius, setCelsius] = useState(''); const handleInputChange = (event) => { const inputValue = event.target.value; setFahrenheit(inputValue); const convertedValue = (inputValue - 32) * (5 / 9); setCelsius(convertedValue.toFixed(2)); }; return ( <div className="container"> <h3>React Js Convert Fahrenheit to Celsius</h3> <label htmlFor="fahrenheit-input"> Fahrenheit: <input type="number" id="fahrenheit-input" className="input" value={fahrenheit} onChange={handleInputChange} /> </label> <br /> <label htmlFor="celsius-input"> Celsius: <input type="number" id="celsius-input" className="input" value={celsius} readOnly /> </label> </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; } .input { margin-top: 5px; padding: 8px; border: 1px solid #ccc; border-radius: 3px; font-size: 16px; } .input:focus { outline: none; border-color: #007bff; box-shadow: 0 0 5px #007bff; } </style> </body> </html>