更改“蚂蚁设计”中的箭头图标

时间:2019-03-15 13:21:36

标签: css sass antd

我创建了一个带有蚂蚁设计子菜单的菜单,并且想要更改展开的箭头图标而没有重要的样式

图片1。 enter image description here

欲望图标-> enter image description here

https://ant.design/components/menu/

<Menu
  onClick={this.handleClick}
  defaultSelectedKeys={['1']}
  mode="inline"                          
>
 <SubMenu title={<span>Home Page</span>}>
     <Menu.Item>1</Menu.Item>
     <Menu.Item>2</Menu.Item>
 </SubMenu>
</Menu>

2 个答案:

答案 0 :(得分:0)

将此代码放入放置在antd css文件之后的css文件中:

.ant-menu-submenu > .ant-menu-submenu-title .ant-menu-submenu-arrow::before {
  content: '';
  position: absolute;
  background: unset !important;
  background-image: unset !important;
  width: 0 !important;
  height: 0 !important;
  border-style: solid;
  border-width: 6px 0 6px 6px;
  border-color: #00d2be transparent transparent transparent;
  transition: transform 0.3s ease-in-out !important;
  transform: rotate(45deg) !important;
  border-radius: 0 !important;
  left: 0;
  top: 50%;
}

.ant-menu-submenu-open > .ant-menu-submenu-title .ant-menu-submenu-arrow::before {
  content: '';
  position: absolute;
  background: unset !important;
  background-image: unset !important;
  width: 0 !important;
  height: 0 !important;
  border-style: solid;
  border-width: 6px 0 6px 6px;
  border-color: #00d2be transparent transparent transparent;
  transition: transform 0.3s ease-in-out !important;
  transform: rotate(-45deg) !important;
  border-radius: 0 !important;
  left: 0;
  top: 50%;
}

.ant-menu-submenu-inline > .ant-menu-submenu-title .ant-menu-submenu-arrow::after,
.ant-menu-submenu-vertical-left > .ant-menu-submenu-title .ant-menu-submenu-arrow::after,
.ant-menu-submenu-vertical-right > .ant-menu-submenu-title .ant-menu-submenu-arrow::after,
.ant-menu-submenu-vertical > .ant-menu-submenu-title .ant-menu-submenu-arrow::after {
  content: none !important;
}

答案 1 :(得分:0)

不确定这是否为时已晚,但我看到一条评论询问是否找到了解决方案。如果您使用 Menu 组件的“expandIcon”参数,您可以将您自己的自定义图标传递给 SubMenu 组件:

 <Menu
        expandIcon={<YourCustomIcon/>}
        selectedKeys={current}
        mode="inline"
    >
        <SubMenu style={{ width: 150 }} key="sub1">
            <Menu.Item key="1">Option 1</Menu.Item>
            <Menu.Item key="2">Option 2</Menu.Item>
            <Menu.Item key="3">Option 3</Menu.Item>
            <Menu.Item key="4">Option 4</Menu.Item>
        </SubMenu>
    </Menu>