inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

BBC 인터랙티브 페이지 "코로나19가 바꿀 사무실의 미래" 클론

JS part 1

첫번째랑 마지막 요가+폰하는 그림이 높이가 꼬였습니다

해결된 질문

465

신혜리

작성한 질문수 3

0

보여드린 스크린샷처럼 첫번째는 여백에 비해 그림이 너무 동떨어지고,  마지막 폰하는 그림이 요가 그림을 스크롤하면 바로 밑으로 나옵니다 😥 

css 코드는

html {
  font-family: "Noto Sans KR", sans-serif;
}

body {
  margin: 0;
}
div,
section,
header,
footer,
p,
h1,
h2 {
  box-sizing: border-box;
}
a {
  color: royalblue;
}
img {
  max-width: 100%;
  height: auto;
}

.global-width {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 1rem;
}

.scroll-graphic {
  position: sticky;
  top: 0;
  height: 100vh;
}

.graphic-item {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  opacity: 0;
  transition: 0.5s;
}

.visible {
  opacity: 1;
}

.scene-img {
  max-height: 100vh;
}

.scroll-text {
  position: relative;
}

.step {
  margin-bottom: 60vh;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: 0.2px solid rgba(216, 216, 216, 0.2);
  box-shadow: rgba(0, 0, 0, 0.3) 0 0 3px;
  background: rgba(255, 255, 255, 0.8);
}

이거구요

js는

(() => {

    const stepElems = document.querySelectorAll('.step');
    const graphicElems = document.querySelectorAll('.graphic-item');
    let currentItem = graphicElems[0];

    for (let i = 0; i < stepElems.length; i++{
        // stepElems[i].setAttribute('date-index', i);
        stepElems[i].dataset.index = i;
        graphicElems[i].dataset.index = i;
    }

    function activate() {
        currentItem.classList.add('visible');
    }


    function inactivate() {
        currentItem.classList.remove('visible');
    }


    window.addEventListener('scroll', () => {
        let step;
        let boundingRect;

        for (let i = 0; i < stepElems.length; i++{
            step = stepElems[i];
            boundingRect = step.getBoundingClientRect();

            if (boundingRect.top > window.innerHeight * 0.1 &&
                boundingRect.top < window.innerHeight * 0.8{

                inactivate();
                currentItem = graphicElems[step.dataset.index];
                activate();
            }
        }
    });
    activate();
})();

이 코드입니다 어떤게 문제일까요..?😥

인터랙티브-웹 클론코딩

답변 4

1

Caesiumy

css파일에서 .scroll-text에 padding-bottom: 1px; 이 빠져있는 거 같아요

자세한 내용은 아래 링크에서!

https://www.inflearn.com/questions/59182

0

신혜리

감사합니다! 다시 살펴보겠습니다 :D

0

1분코딩

보니까 영상에 그 부분 설명이 빠져있더라고요^^;
강의 노트에 텍스트로 같이 보실 수 있게 수정했습니다!
그리고 감사드려요 Caesiumy님! ㅎㅎ

0

신혜리

:D 헉 감사합니다! 

LocationPermission.denied관련 질문입니다

0

585

1

writeHead 부분

0

466

1

로그인페이지, 회원가입페이지 못들어가게하는 부분

0

516

1

강의에서 사용하고 있는 next.js 버전으로 설치는 어떻게 하나요?

0

2342

1

[공유] react-mention 항상 커서 위에 나오게 수정

2

882

3

videocontrollor dispose

0

427

1

user 과 auth에서 인증 부분

0

447

1

onlogotap함수의 video nullable관련질문

0

387

1

채팅대화에서 시간이 중복될경우 안보이게 하는방법 문의.

0

542

1

쿠키에 대해서

0

315

1

next.js 버전이 12인건가요?

0

367

1

오류났을때 참고

3

685

3

style.css 오류

0

307

1

actions 함수 관련 질문

2

400

1

새가 원래자리로 돌아올때도 transition 시간이 필요한데. 돌아올때는 바로 돌아오록 하는 Tip 이 있을까요?

0

249

0

classList 오류가 계속 납니다..ㅜㅜ

0

395

0

새 애니메이션이 작동하지 않습니다.

0

239

1

action이 true일때 실행되는데 false에서 초기화가 안되요ㅠ

0

334

2

오류가 나는데 찾지를 못하겠어요...

0

375

2

안녕하세요 ~~ 배경으로 깔린 음악이 너무 궁금하네요 ㅎㅎ

0

540

2

actions[action] is not a function 라고 뜹니다

0

993

5

forEach로 작성해봤습니다!

1

285

1

안녕하세요, step부분 문의 드립니다.

0

218

1

질문있습니다!

2

310

2