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"> // Add the import statement for useState hook const { useState } = React; // Define the App component const App = () => { const link = "https://fontawesomeicons.com"; const imageSrc = "https://www.sarkarinaukriexams.com/images/import/sne10272423583.png"; return ( <div className="container"> <h3 className="heading">React JS Use Image as Link</h3> <a href={link} target="_blank" className="link"> <img src={imageSrc} alt="Image Description" className="image" /> </a> </div> ); }; ReactDOM.render(<App />, document.getElementById("app")); </script> <style> body { margin: 0; } .container { max-width: 400px; margin: 0 auto; padding: 20px; font-family: Arial, sans-serif; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); position: relative; } .heading { font-size: 24px; font-weight: bold; margin-bottom: 10px; } .link { display: block; text-decoration: none; overflow: hidden; border-radius: 8px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); } .image { width: 100%; height: auto; transition: transform 0.3s ease; } .link:hover .image { transform: scale(1.1); } .image:hover { cursor: pointer; } /* If you want to style the link text (optional) */ .link .link-text { display: block; padding: 10px; text-align: center; font-size: 18px; color: #333; background-color: #f5f5f5; } </style> </body> </html>