Set Button on Image with CSS

You can try to run the following code to set button on an image:


Live Demo

<!DOCTYPE html>
         .box {
            position: relative;
            width: 100%;
            max-width: 250px;
         .box img {
            width: 100%;
            height: auto;
         .box .btn {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
      <div class = "box">
         <img src = "" alt = "Current Affairs">
         <button class = "btn">Button</button>

Updated on: 24-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started