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.production.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.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; // Define the App component const App = () => { const [fontSize, setFontSize] = useState(16); // Function to handle font size changes const handleFontSizeChange = (event) => { const newSize = parseInt(event.target.value, 10); // Parse the input value as an integer setFontSize(newSize); }; return ( <div className="container"> <h3>React Js Change font size dynamically</h3> <div className="dynamic-font" style={{ fontSize: `${fontSize}px` }}> Text with dynamic font size </div> <input className="font-size-input" type="number" value={fontSize} onChange={handleFontSizeChange} min="10" // Set the minimum value allowed max="50" // Set the maximum value allowed /> </div> ); }; ReactDOM.render(<App />, document.getElementById("app")); </script> <style> /* Styles for the container */ .container { display: flex; flex-direction: column; align-items: center; justify-content: center; } /* Styles for the font-size-input */ .font-size-input { margin-top: 10px; font-size: 16px; padding: 8px 12px; border-radius: 4px; background-color: #fff; text-align: center; width: 100px; } </style> </body> </html>