gpt4 book ai didi

angular - 如何配置 PrimeNG 侧边栏为标题留出空间并能够将 Canvas 向右推

转载 作者:行者123 更新时间:2023-12-04 04:31:28 26 4
gpt4 key购买 nike

我正在使用 Angular 7PrimeNG 8 构建网站。
顶部有固定标题,左侧有侧边栏导航菜单的网页布局。

我的预期行为是当侧边栏切换时,它不会隐藏标题,内容也会向右移动。

enter image description here

我检查了primeng文档,但没有提供这样的功能。
https://www.primefaces.org/primeng/#/sidebar

最佳答案

您可以简单地使用 css 和 html 实现,例如,当悬停在容器上时,我使用纯 CSS 扩展侧栏,您可以使用 JS 处理单击事件以扩展它:

* {
margin: 0;
}
nav{
height:70px;
background-color: green;
}
.container{
display: flex;
height: calc(100vh - 70px);
}
.container .main-body{
width: 100%;
}
.container aside{
width: 0;
overflow-y: auto;
transition: all 0.5s;
background-color: yellow;
}
/*Im using hover event to expand sidebar for example, you can use JS to handle click event*/
.container:hover aside{
width: 200px;
}
<nav></nav>
<section class="container">
<aside></aside>
<div class="main-body">Hover me to display side bar</div>
</section>

这里我包含了 an working example for Angular project .Happy coding !!!

关于angular - 如何配置 PrimeNG 侧边栏为标题留出空间并能够将 Canvas 向右推,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56944139/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com