【问题标题】:Subtitle or child element in Antd Menu.ItemAntd Menu.Item 中的副标题或子元素
【发布时间】:2021-07-26 15:16:02
【问题描述】:

我看到您可以在Antd Menu.Item 中使用wrap words,但我想知道您是否可以为菜单项创建(样式化的)子元素或副标题。类似:

------
**Item 1**
---
**Item 2**
This item is second
---
**Item 3**
------

我尝试添加<div><p>,如下所示,但它似乎被隐藏了。

<Menu.Item key={eventKey} {...props}
    <span>{item.title}</span>
    <div>A styled subtitle here</div>
</Menu.Item>

【问题讨论】:

    标签: antd


    【解决方案1】:

    我认为您可以在 Menu.Item 中使用纯 html 元素和 css。

    也许您需要使用heightlineHeight 设置并查看inspect 视图。

    这个基本示例对我有用:

    <Menu.Item key="1" style={{ lineHeight: '20px' }}>
       <span>
          Option 1
       </span>
       <br />
       <span>Test</span>
    </Menu.Item>
    

    Here 是一个有效的 Stackblitz。

    &lt;h1&gt; 等元素也能正常工作。

    【讨论】:

    • 啊,是的,我认为 CSS 是我所缺少的,因为 height/lineHeight 需要被覆盖。谢谢!
    猜你喜欢
    • 2020-05-16
    • 2022-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-23
    • 2020-07-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多