简体   繁体   English

MUI 面包屑 - 如何隐藏第一项和分隔符

[英]MUI Breadcrumbs - How To Hide First Item And Separator

I'm using the MUI Breadcrumbs component on a site I'm working on and I'm just about done but I'm trying to hide the first item in the path.我正在我正在处理的网站上使用 MUI Breadcrumbs 组件,我即将完成,但我试图隐藏路径中的第一项。 I'm able to hide the actual word itself, but I can't figure out how to hide the separator.我能够隐藏实际的单词本身,但我不知道如何隐藏分隔符。

For example, this is how it's structured now:例如,这就是它现在的结构:

"W > X > Y" “W > X > Y”

This is how I want it to look:这就是我希望它看起来的样子:

"X > Y" “X > Y”

This is what I'm currently showing because I can't hide the first separator:这是我当前显示的内容,因为我无法隐藏第一个分隔符:

"> X > Y" "> X > Y"

Anyone have any ideas on how to hide that first separator?有人对如何隐藏第一个分隔符有任何想法吗?

You can add a custom class to the Breadcrumbs component like this:您可以将自定义 class 添加到Breadcrumbs组件,如下所示:

<Breadcrumbs className="breadcrumbsCustomStyle"

and using css set display: none;并使用 css 设置display: none; for the first two li children of this class like this:对于这个 class 的前两个li孩子,如下所示:

.breadcrumbsCustomStyle li:first-child,
.breadcrumbsCustomStyle li:nth-child(2) {
    display: none;
}

You can take a look at this sandbox for a live working example of this approach.您可以查看此沙箱,了解此方法的实时工作示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM