【发布时间】:2018-06-06 07:06:36
【问题描述】:
我目前正在制作一个没有完整高度的侧边栏。我正在尝试将标题的高度减去窗口屏幕的高度。
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;
`;
我有一个关于将 window.onload 传递给 css 的问题 height 的属性当前代码在 devtools 中没有显示任何 px。
请帮我解决这个问题。谢谢!
【问题讨论】:
标签: javascript css reactjs styled-components