공감 버튼 누르면 이미지 표시

공감 버튼 누르면 이미지 표시

QA

공감 버튼 누르면 이미지 표시

본문

2105789910_1599043274.3327.jpg

 

위 사진처럼 좋아요 버튼을 누르면 뿜업 이미지 처럼 잠깐 나오게 하려면 어떻게 해야하나요?

그누보드 5.3입니다..!

이 질문에 댓글 쓰기 :

답변 1

https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_button_on_image

에 아래 코드를 복사해서 실행시켜 보세요.

 

대략적인 원인은 이미지위에 원하는 이미지를 같이 디스플레이 시키고,  그것의 스타일을 display: none으로 세팅해 놓았다가,  버튼을 누르면 display: block형태로 보여 주었다가 (필요하면 css transition도 적용시켜보세요.) 일정 시간 지나면

다시 display: none으로 세팅해 보세요


<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<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: #555;
  color: white;
  font-size: 16px;
  padding: 12px 24px;
  border: none;
  cursor: pointer;
  border-radius: 5px;
  text-align: center;
  display: none;
}
.container .btn:hover {
  background-color: black;
}
</style>
</head>
<body>
<h2>Button on Image</h2>
<p>Add a button to an image:</p>
<div class="container">
  <img src="img_snow.jpg" alt="Snow" style="width:100%">
  <button id="btnID" class="btn">Button</button>
</div>
<button onclick="myFunction()">Button</button>
<script>
function myFunction() {
    var x = document.getElementById('btnID');
    
        x.style.display = 'block';
        setTimeout(function(){ x.style.display = 'none';  }, 2000);
    
}
</script>
</body>
</html>
답변을 작성하시기 전에 로그인 해주세요.
전체 123,663 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT