Comments (13)
第一个问题:#42 有待讨论和优化
第二个问题:
我这边正常的
from antd-admin.
from antd-admin.
第一个问题:左侧导航菜单过多,不能实现上下滚动的问题
height: 100%;
overflow-y: auto;
components/layout/sider.js
const Sider = ({ siderFold, location }) => {
const menusProps = {
siderFold,
location,
};
return (
<div className={styles.left_bar}>
<div className={styles.logo}>
<img alt="{config.logoText}" src={config.logoSrc} />
{siderFold ? '' : <span>{config.logoText}</span>}
</div>
<div className={styles.left_menus}>
<Menus {...menusProps} />
</div>
</div>
);
};
export default Sider;
components/layout/main.less
@import "../vars.less";
.layout {
position: relative;
height: 100vh;
&.withnavbar {
.main {
margin-left: 0;
}
}
&.fold {
.sider {
width: 42px;
.left_bar {
overflow-y: visible;
}
.logo {
img {
width: 28px;
margin: 6px 7px;
}
}
:global {
.ant-menu-root {
width: 100%;
& > .ant-menu-item {
padding: 0;
text-align: center;
.anticon {
font-size: 14px;
margin-right: 0;
}
}
& > .ant-menu-submenu {
& > .ant-menu-submenu-title {
padding: 0;
text-align: center;
.anticon {
font-size: 14px;
margin-right: 0;
}
&::after {
display: none;
}
}
}
}
}
}
.main {
margin-left: 42px;
}
}
.sider {
width: 224px;
background: #3e3e3e;
position: absolute;
overflow: visible;
height: 100vh;
transition: @transition-ease-out;
box-shadow: @shadow-1;
z-index: 1994;
color: #999;
&.light {
background: #fff;
.switchtheme {
background: #fff;
border-top: solid 1px #f8f8f8;
}
}
.left_bar {
height: 100%;
overflow-y: auto;
}
.logo {
text-align: center;
height: 40px;
line-height: 40px;
cursor: pointer;
margin: 28px 0;
transition: @transition-ease-out;
overflow: hidden;
img {
width: 40px;
margin-right: 8px;
transition: @transition-ease-out;
}
span {
vertical-align: text-bottom;
font-size: 16px;
text-transform: uppercase;
display: inline-block;
}
.anticon {
transition: @transition-ease-out;
}
}
.switchtheme {
width: 100%;
position: absolute;
bottom: 0;
height: 48px;
background-color: @dark-half;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 16px 0 24px;
overflow: hidden;
z-index: 1000;
span {
white-space: nowrap;
overflow: hidden;
}
:global {
.anticon {
min-width: 14px;
margin-right: 8px;
font-size: 14px;
}
}
}
:global {
.ant-menu-dark,
.ant-menu-dark .ant-menu-sub {
color: #999;
}
.ant-menu {
transition: @transition-ease-out;
.ant-menu-item,
.ant-menu-submenu-title {
overflow: auto;
white-space: normal;
}
}
}
}
.header {
:global .ant-menu-horizontal {
& > .ant-menu-submenu {
float: right;
}
border: none;
}
box-shadow: @shadow-2;
position: relative;
.siderbutton {
height: 47px;
width: 47px;
line-height: 47px;
text-align: center;
font-size: 18px;
cursor: pointer;
position: absolute;
transition: @transition-ease-in;
&:hover {
color: @primary-color;
background-color: fade(@primary-color, 15%);
}
}
}
.bread {
height: 64px;
line-height: 64px;
padding: 0 24px;
margin-bottom: -24px;
}
.main {
margin-left: 224px;
overflow: auto;
height: 100vh;
transition: @transition-ease-out;
.container {
margin: 24px;
.content {
min-height: e("calc(100vh - 184px)");
position: relative;
:global .content-inner {
background: #fff;
padding: 24px;
box-shadow: @shadow-1;
min-height: e("calc(100vh - 184px)");
}
}
}
}
.footer {
height: 48px;
line-height: 48px;
text-align: center;
font-size: 12px;
color: #999;
background: #fff;
box-shadow: @shadow-2;
width: 100%;
}
}
:global .ant-menu-dark {
color: #999;
background-color: #3e3e3e;
.ant-menu-submenu-title:hover,
.ant-menu-submenu:hover {
color: @primary-color;
}
.ant-menu-sub {
color: #999;
}
.ant-menu-submenu-selected {
color: @primary-color;
&:not(.ant-menu-submenu-open) {
background-color: @dark-half;
}
}
.ant-menu-item,
.ant-menu-submenu-title {
& > a {
color: #999;
}
&:hover > a {
color: @primary-color;
}
}
&.ant-menu-inline {
.ant-menu-item-selected {
background-color: @dark-half;
}
}
.ant-menu-item-selected {
color: @primary-color;
background-color: @dark-half;
& > a {
color: @primary-color;
}
&:hover {
background-color: @dark-half;
}
}
}
.popovermenu {
width: 280px;
left: 12px!important;
:global .ant-popover-inner-content {
padding: 0;
.ant-menu-inline .ant-menu-item,
.ant-menu-vertical .ant-menu-item {
border-right: 0;
height: 48px;
line-height: 48px;
}
.ant-menu-inline .ant-menu-item-selected,
.ant-menu-inline .ant-menu-selected {
border-right: 0;
}
}
}
.spin {
:global .ant-spin-container {
height: 100vh;
}
}
from antd-admin.
@wanghao524151 这样会有另外一个问题,就是菜单收拢时,二级菜单被overflow了
from antd-admin.
from antd-admin.
对的,使用了overflow:hidden;
或者overflow-y:hidden;
收拢时都会使二级菜单显示不了
from antd-admin.
我加了这个:收起来的时候fold left_bar去除overflow-y,这样就可以了
&.fold {
.sider {
width: 42px;
.left_bar {
overflow-y: visible;
}
}
}
from antd-admin.
@wanghao524151 讲道理可以,晚点我加上,极端情况就是收拢也需要滚动,不过这应该是最好的解决方法了
from antd-admin.
fix: a2abe41
from antd-admin.
我自己的解决方案是取消了侧边栏的固定,整页滚动
from antd-admin.
还有就是某些页面可能不在侧边栏菜单中进行导航,比如某个列表中某一项的详情页,但是是需要菜单高亮的。我目前的做法是从菜单数据中找到这条路径,如果找不到,就截取最后一段继续找。
比如 /product/list/123
我会依次寻找 /product/list/123,/product/list,/product。。。
这种做法需要约定无菜单的页面与有菜单的页面的路径关系
from antd-admin.
@myqianlan 最新的代码没有问题了啊
from antd-admin.
@zuiidea
1.当前方案收拢时并不能上下滚动
2.当前方案并未考虑到无侧边栏菜单页面在侧边栏高亮其父级菜单
from antd-admin.
Related Issues (20)
- Change proxy HOT 1
- Failed to load resource: the server responded with a status of 404 (Not Found) 开发环境是正常的,打包后浏览器打开出问题 HOT 3
- 自己写登录接口 HOT 1
- 强强
- 能否提供个typescript版的 HOT 1
- 切换菜单时报错
- 项目启动时报 [ERR_ASSERTION]: filePath not found of antd/lib/locale-provider/pt_BR
- 启动直接报错,我的node版本是18.12.1 HOT 3
- 有没有项目说明文档 HOT 2
- 打开之后无法加载页面 HOT 2
- 111
- Select tag mode bug HOT 1
- npm run start doesn't work HOT 5
- macbook中出现Assertion Error,无法npm run start HOT 3
- develop分支,修改主题色无效 HOT 2
- Proxy 问题 HOT 11
- 技术问题,怎么实现受控表单 HOT 2
- Demo Prevew version diffirence git clone version? HOT 2
- pageing not working HOT 1
- graphgl HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from antd-admin.