질문이요~
187
작성한 질문수 15
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<style media="screen">
body[data-char='ragirl'] {
background: #ff7200;
}
body[data-char='ilbuni'] {
background: dodgerblue;
}
body{
height:500vw;
font-family: 'Apple SD Gothic Neo', 'Roboto', 'Noto Sans KR', NanumGothic, 'Malgun Gothic', sans-serif;
-webkit-overflow-scrolling: touch;
color: #555;
}
.world{
position: fixed;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
perspective: 1000px;
}
.house {
width: 100vw;
height: 100vh;
transform: translateZ(-490vw);
transform-style: preserve-3d;
}
.wall-front-a { transform: translateZ(300vw); }
.wall-front-b { transform: translateZ(50vw); }
.wall-front-c { transform: translateZ(-200vw); }
.wall-front-d { transform: translateZ(-500vw); }
.wall-content{
position: absolute;
display:flex;
align-items: center;
justify-content: center;
height: 100vh;
}
h2{
font-size: 15rem;
}
</style>
</head>
<body>
<div class="click-button">
<button class="buttonboy" data-char="ilbuni"></button>
<button class="buttongirl" data-char="ragirl"></button>
</div>
<div class="progress-bar-con">
<div class="progress-bar"></div>
</div>
<div class="world">
<div class="house">
<div class="wall-front-a">
<div class="wall-content">
<h2 class="wall-title">안녕하세요</h2>
<!-- <img src="Bible.png" alt=""> -->
</div>
</div>
<div class="wall-front-b">
<div class="wall-content">
<h2 class="wall-title">Hello</h2>
<!-- <img src="K-108.png" alt=""> -->
</div>
</div>
<div class="wall-front-c">
<div class="wall-content">
<h2 class="wall-title">Hola</h2>
<!-- <img src="Bible.png" alt=""> -->
</div>
</div>
<div class="wall-front-d">
<div class="wall-content">
<h2 class="wall-title">こんにちは</h2>
<!-- <img src="K-108.png" alt=""> -->
</div>
</div>
</div>
</div>
<script type="text/javascript">
(function () {
const houseElem = document.querySelector('.house');
let maxScrollValue;
window.addEventListener('scroll',function () {
const scrollPer = pageYOffset / maxScrollValue;
const zMove = scrollPer *980 -450;
houseElem.style.transform = 'translateZ('+zMove+'vw)';
})
function resize() {
maxScrollValue = document.body.offsetHeight - window.innerHeight;
}
resize();
})();
</script>
</body>
</html>
복습하면서 예제랑 비슷하면서 간단하게 만들려고 위에처럼 코드를 짜봤는데 스크롤 움직이면 제대로 작동은 하는데 폰트들이 왼쪽으로 휘면서 커지네요...
이건 어떤 문제가 있는걸까요??
답변 1
0
CSS에
.wall-front-a, .wall-front-b, .wall-front-c, .wall-front-d { display: flex; justify-content: center; }
를 추가해보세요.
각 wall 내부의 텍스트가 가운데 정렬이 안되어있어서 그렇습니다~
왼쪽/오른쪽 동작시 딜레이 문제
0
93
1
변수 범위 관련 질문
0
106
1
perspective 문의
0
102
1
생성자 함수를 클래스 함수로 변경 하고 this 오류 관련
0
150
1
스크롤이 중간 위치에 있을 때 창의 크기를 변환하면 생기는 문제
0
127
1
animation이벤트 질문이요!
0
72
1
resize handler에서 질문이 있습니다.
0
111
1
카드 뒤집힐 때 F가 보인 이유
0
149
1
3d 뒤집기 추가효과
0
218
1
전진! 3D 스크롤 21 강의 질문
1
171
1
eventlistener 질문
0
149
1
zMove 를 1000으로 설정하는 이유에 대하여.
0
168
1
[정보-23강] ES6 class 문법으로 공부하시는 분들!! 화살표 함수로도 시도해보셔요!
1
191
1
동적으로 html 생성 후 이벤트 위임 질문 있습니다.
0
266
1
rotateY()에서 deg에 따른 차이
0
197
1
코드 작성 순서
0
276
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
361
2
house 부분에도 width , height 부분을 꽉 차게 주신 부분이 제가 이해한게 맞는지 궁금합니다.
0
305
2
left:-400vw 가 아닌 translateZ(100vw); 을 입력하신 이유가 궁금합니다.
0
306
2





