Currently, I'm working on a sidebar that doesn't have its full height. My goal is to calculate the difference between the height of the header and the height of the window screen.
const setSidebarHeight = () => {
return (window.onload = () => {
if (document.getElementById('navigation-bar')) {
return ( window.innerHeight - document.getElementById('navigation-bar').clientHeight );
}
});
}
const SideBarDiv = styled.div`
color: #232323;
background-color: #f4f3f4;
float: left;
position: relative;
z-index: 100;
height: ${setSidebarHeight()}px;
`;
I'm wondering how to appropriately use window.onload
to dynamically adjust the height
attribute in CSS. The current code does not display any pixel values in the browser developer tools.
If anyone has insight on this issue, I would greatly appreciate your help. Thank you!