여러분이 사용하고 계신 브라우저는 HTML5를 지원하지 않기 때문에 몇몇 요소가 제대로 보이도록 JScript를 사용하고 있습니다. 하지만 여러분의 브라우저 설정에서 스크립트 기능이 꺼져있으므로, 현재 페이지를 제대로 확인하시려면 스크립트 기능을 켜주셔야 합니다. How To - 이미지의 버튼
How To – 이미지의 버튼
2개월전 작성
2개월전 수정

w3.css

이미지의 버튼

CSS를 사용하여 이미지에 버튼을 추가하는 방법을 알아보자.

이미지 위에 버튼을 추가하는 방법

1단계) HTML 추가
<div class="container">
  <img src="img_snow.jpg" alt="Snow">
  <button class="btn">Button</button>
</div>
2단계) CSS 추가
/* Container needed to position the button. Adjust the width as needed */
.container {
  position: relative;
  width: 50%;
}

/* Make the image responsive */
.container img {
  width: 100%;
  height: auto;
}

/* Style the button and place it in the middle of the container/image */
.container .btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  background-color: #555;
  color: white;
  font-size: 16px;
  padding: 12px 24px;
  border: none;
  cursor: pointer;
  border-radius: 5px;
}

.container .btn:hover {
  background-color: black;
}
기본 예시
예제 보기
참고
Mingg`s Diary
밍구
공부 목적 블로그