screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script> </head> <body> <div id="app"></div> <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 type="text/babel"> const { useState } = React; function App() { const [isLarge, setIsLarge] = useState(true); return ( <div className='container'> <h3>React Js Change Font Size using Tenary Operator</h3> <button className='button' onClick={() => setIsLarge(!isLarge)}> Toggle Font Size </button> <p style={{ fontSize: isLarge ? '24px' : '16px' }}> This is some text with a dynamic font size. </p> </div> ); } ReactDOM.render(<App />, document.getElementById('app')); </script> <style scoped> .container { max-width: 600px; margin: 0 auto; padding: 20px; border-radius: 5px; box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.2); } /* Button Styles */ .button { background-color: #3498db; color: #fff; padding: 10px 20px; font-size: 16px; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.3s ease; } .button:hover { background-color: #2980b9; } /* Text Styles */ .text { font-size: 18px; margin-top: 20px; transition: font-size 0.3s ease; } </style> </body> </html>