Computer >> 컴퓨터 >  >> 프로그램 작성 >> CSS

CSS를 사용하여 이미지에 버튼 설정

<시간/>

다음 코드를 실행하여 이미지에 버튼을 설정할 수 있습니다.

예시

<!DOCTYPE html>
<html>
   <head>
      <style>
         .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%);
         }
      </style>
   </head>
   <body>
      <div class = "box">
         <img src = "https://www.tutorialspoint.com/videotutorials/images/current_affairs_home.jpg" alt = "Current Affairs">
         <button class = "btn">Button</button>
      </div>
   </body>
</html>