기능: 모바일에서 hover를 터치 효과로 바꾸기

dkahsem27·2022년 3월 18일
0

기능

목록 보기
5/6

스크립트에 document.addEventListener("touchstart", function() {}, true); 코드를 넣어주면 모바일화면에서 터치시 hover에 적용한 효과가 나타남

  • html
<div class="hover">some hover effect</div>

<script>
document.addEventListener("touchstart", function() {}, true);
</script>
  • css
.hover {opacity: 0;}

&:hover,
&:focus,
&:active .hover {opacity: 1;}
profile
초보초보

0개의 댓글