screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script> <script src="https://unpkg.com/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, useEffect, useRef } = React; function App() { const imageUrl = 'https://www.sarkarinaukriexams.com/images/import/sne4446407201.png'; const openImageInNewTab = () => { window.open(imageUrl, '_blank'); }; return ( <div className='container'> <h3>React js Open Image New Tab onclick Image</h3> <p>Click the image to open it in a new tab:</p> <img src={imageUrl} alt="Click to open in new tab" onClick={openImageInNewTab} style={{ cursor: 'pointer' }} /> </div> ); } ReactDOM.render(<App />, document.getElementById('app')); </script> <style> .container { max-width: 800px; margin: 0 auto; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); text-align: center; } /* Style for the paragraph */ .container p { font-size: 16px; color: #333; /* You can change the color to your preference */ } /* Style for the image */ .container img { width: 200px; /* You can adjust the width as needed */ height: auto; border: 2px solid #333; /* You can change the border color to your preference */ border-radius: 5px; cursor: pointer; } /* Style for the image when hovered */ .container img:hover { border-color: #007bff; /* Change this color to your preference on hover */ } </style> </body> </html>