javascript - 在 styled-components 中传递 window.onload 的函数
问题描述
我目前正在研究一个没有完整高度的侧边栏。我试图让标题的高度减去窗口屏幕的高度。
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;
`;
我有一个关于将 a 传递window.onload
给 css 的问题height
,当前代码的属性在 devtools 中没有显示任何 px。
请帮我解决这个问题。谢谢!
解决方案
推荐阅读
- sql - 从表中为选择的每一行选择任意行
- r - 计算数据集每一列的比例(百分比)
- angular - 无法加载角度生成的网页(ng build --prod)
- python - 你能把 python 编程到 Arduino 上吗
- snowflake-cloud-data-platform - 我们可以在雪花数据库的物化视图中使用枢轴函数吗
- android - 在 Jetpack Compose UI 中设置内容视图的方法
- python - 如何用另一个字典列表过滤字典列表
- python - 是否有将根据训练数据计算的 WOE 添加到整个数据集的功能?(Python)
- azure - 如何在 Azure Web App 中为容器装载 docker 卷?
- google-bigquery - BigQuery ML K-means 与训练模型后的新数据集