카드를 멈출수도 있을까요?
244
작성한 질문수 2
안녕하세요! 이전 강의에서 animation-fill-mode를 사용해서 뒤집힌 후에 카드를 멈추고 싶은데요.
구글링하다 forwards라는 옵션을 주면 된다고 하는데 .card 클래스에 적용 해도 저는 원래 카드 면으로 돌아옵니다.
혹시 animation-fill-mode 말고 다른 속성 값을 적용해야 할까요? 아니면 제가 잘못 적용 한건가요?
답변 1
0
이 예제는 transition을 이용하고 있고요,
animation-fill-mode는 transition이 아닌 animation에 있는 속성이랍니다.
이 예제처럼 hover CSS로 처리하면, 마우스가 빠졌을 때는 어차피 원래대로 돌아오게 되어있으므로
자바스크립트로 처리하시면 됩니다.
아래는 CSS에 flip 클래스를 정의해두고, 카드를 클릭하면 뒤집히는 예제입니다.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Interactive Web</title>
<style>
.world {
display: flex;
align-items: center;
justify-content: center;
width: 60vw;
height: 60vh;
background: #fff000;
perspective: 500px;
}
.card {
position: relative;
width: 100px;
height: 150px;
margin: 1em;
transform: rotateY(0deg);
transition: 1s;
transform-style: preserve-3d;
}
.card.flip {
transform: rotateY(180deg);
}
.card-side {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
border-radius: 0.5em;
font-size: 1.5rem;
backface-visibility: hidden;
}
.card-side-front {
z-index: 1;
background: white;
}
.card-side-back {
background: red;
transform: rotateY(180deg);
}
</style>
</head>
<body>
<div class="world">
<div class="card">
<div class="card-side card-side-front">F</div>
<div class="card-side card-side-back">B</div>
</div>
</div>
<script>
const card = document.querySelector('.card');
card.addEventListener('click', function () {
this.classList.toggle('flip');
});
</script>
</body>
</html>
왼쪽/오른쪽 동작시 딜레이 문제
0
93
1
변수 범위 관련 질문
0
106
1
perspective 문의
0
100
1
생성자 함수를 클래스 함수로 변경 하고 this 오류 관련
0
150
1
스크롤이 중간 위치에 있을 때 창의 크기를 변환하면 생기는 문제
0
127
1
animation이벤트 질문이요!
0
71
1
resize handler에서 질문이 있습니다.
0
110
1
카드 뒤집힐 때 F가 보인 이유
0
149
1
3d 뒤집기 추가효과
0
217
1
전진! 3D 스크롤 21 강의 질문
1
171
1
eventlistener 질문
0
149
1
zMove 를 1000으로 설정하는 이유에 대하여.
0
168
1
[정보-23강] ES6 class 문법으로 공부하시는 분들!! 화살표 함수로도 시도해보셔요!
1
191
1
동적으로 html 생성 후 이벤트 위임 질문 있습니다.
0
265
1
rotateY()에서 deg에 따른 차이
0
197
1
코드 작성 순서
0
275
1
이미지가 없는데 첨부파일을 다운 받는 방법이 있나요??
1
394
1
'이벤트 위임 보강 영상'에 있는 예제 html이 안 보입니다
0
265
2
섹션5 자바스크립트 이벤트 다루기 질문
1
243
1
[#전진! 3D 스크롤 11] mousePos 공식 질문 있습니다!
0
423
2
css 는 직접 작성을 해야하는걸까용?
0
326
1
translateZ 에 px 이 아닌 vw 로 값을 주신 이유가 있을가요?
0
360
2
house 부분에도 width , height 부분을 꽉 차게 주신 부분이 제가 이해한게 맞는지 궁금합니다.
0
305
2
left:-400vw 가 아닌 translateZ(100vw); 을 입력하신 이유가 궁금합니다.
0
306
2





