-
카테고리
-
세부 분야
프론트엔드
-
해결 여부
미해결
선생님 이부분 질문있습니다.
21.01.06 05:16 작성 조회수 121
0
type:'sticky',
//2
heightNum:5,
scrollHeight:0,
objs:{
container: document.getElementById('scroll-section-2')
}
},
{
type:'sticky',
//3
scrollHeight:0,
heightNum:5,
objs:{
//container: document.querySelector('#scroll-section-3')
container: document.getElementById('scroll-section-3')
}
}
];
function setLayout(){
for(let i=0; i<sceneInfo.length; i++){
sceneInfo[i].scrollHeight = sceneInfo[i].heightNum * window.innerHeight;
sceneInfo[i].objs.container.style.height=sceneInfo[i].scrollHeight;
//기본적으로 문자열을 설정해야하나 ${--- } << ---이부분에 변수이름을 적용 가능
}
console.log(sceneInfo);
}
setLayout();
})();
주석과는 관계 없이 getelementbyid 로 id객체를 가져와서 그 객체에 style.height로 값을 저런식으로 주게되면 왜 적용이 안되는건가요?
답변을 작성해보세요.
0
1분코딩
지식공유자2021.01.09
getElementById로 하셔도 똑같이 적용됩니다~ #을 빼주신 것도 잘 해주셨는데..
무엇을 이용하든, CSS에는 단위가 들어가야하기 때문에 setLayout에서 height를 적용하실 때
`${sceneInfo[i].scrollHeight}px`;
주석에 써주신 것 처럼 이런 식으로 처리해주시면 됩니다.
다른 질문은 제가 확인을 못했나보네요, 한번 살펴볼게요!
0
답변 2