在中心反应 js 语义菜单项

React js Semantic Menu items on center

您好,我无法将我的内容放在这个中心 div

代码: https://codesandbox.io/s/hungry-https-c5432

我试过将内联显示放在 h5 上,但还是不行

<div className="App">
  <Menu
    className="borderless"
    style={{ width: "240px", height: "100vh" }}
    vertical
  >
    <Menu.Item className="logo">
      <Image src={logo} style={{ width: "50px", height: "50px" }} />
      <h5>E M A S A</h5>
      <Divider style={{ color: "#000 !important" }} />
    </Menu.Item>
  </Menu>
</div>

css:

.ui.menu {
  border-radius: 0px !important;
  border: 0px !important;
  box-shadow: none !important;
  background-color: #252631 !important;
}
.ui.menu .item {
  padding: 8px !important;
}
r {
  margin-bottom: 0 !important;
}r {
  margin-bottom: 0 !important;
}

为了将 img 居中对齐,您可以添加 margin: 0 auto; display: block;

为了对齐文本 h5 你可以添加 text-align: center;

检查此 link:https://codesandbox.io/embed/sweet-glitter-9toif?fontsize=14&hidenavigation=1&theme=dark

您需要更新CSS,这里是demo link

JSX Code

 <Menu
    className="borderless"
    style={{ width: "240px", height: "100vh" }}
    vertical>
    <Menu.Item className="logo">
      <h5>
        <Image
          src={logo}
          style={{ width: "50px", height: "50px", marginRight: "10px" }}
        />
        <span>E M A S A</span>
      </h5>
      <Divider style={{ color: "#000 !important" }} />
    </Menu.Item>
  </Menu>

CSS

.ui.menu {
  border-radius: 0px !important;
  border: 0px !important;
  box-shadow: none !important;
  background-color: #252631 !important;
}

.ui.menu .item {
  padding: 8px !important;
  text-align: center;
}

.ui.menu .item h5 {
  text-align: center;
}

.ui.divider {
  margin-bottom: 0 !important;
}

img.ui.image {
  display: inline-block;
}

我知道您需要将它们放在同一行,因此将其添加到 css .ui.vertical.menu .item{display:flex; justify-content:center;}