screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <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"> function App() { const condition = true; // You need to define the 'condition' variable let content; if (condition) { content = <div>Content when condition is true</div>; } else { content = <div>Content when condition is false</div>; } return ( <div className='container'> <h3 className='classNameForH3'>React Js if else conditional Rendering</h3> <p className='classNameForP'>{content}</p> </div> ) } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { padding: 20px; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); text-align: center; } .classNameForH3 { font-size: 24px; color: #333; margin-bottom: 10px; } .classNameForP { font-size: 16px; color: #666; } </style> </body> </html>