<!DOCTYPE html> <html> <head> <style> .container { position: relative; width: 100%; max-width: 400px; } .container img { width: 100%; height: auto; } .container .btn { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); background-color: #f1f1f1; color: black; font-size: 16px; padding: 16px 30px; border: none; cursor: pointer; border-radius: 5px; text-align: center; } .container .btn:hover { background-color: black; color: white; } </style> </head> <body> <h2>Button on Image</h2> <p>Add a button to an image:</p> <div class="container"> <img src="img_lights.jpg" alt="Snow" style="width:100%"> <button class="btn">Button</button> </div> </body> </html> |